Edit D:\rfid\apache-tomcat-8.5.32\bin\commons-daemon-native.tar
commons-daemon-1.1.0-native-src/LICENSE.txt 0100664 0001750 0001750 00000026136 10210071042 020625 0 ustar 00mark mark 0000000 0000000 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. commons-daemon-1.1.0-native-src/RELEASE-NOTES.txt 0100664 0001750 0001750 00000003522 13201062030 021503 0 ustar 00mark mark 0000000 0000000 ================================================================================ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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 Commons Daemon 1.1 Release Notes This document contains the release notes for this version of the Apache Commons Daemon package, and highlights new features compared to the 1.0 releases. New Features ------------ - The minimum required Java version has been increased from Java 1.3 to Java 6 - Explicit support has been added for Java 9 - The minimum target platform for Windows has been increased to Windows XP Bug Fixes --------- - Please see the change log http://commons.apache.org/proper/commons-daemon/changes-report.html Feedback -------- Open source works best when you give feedback: http://commons.apache.org/daemon/ Please direct all bug reports to JIRA https://issues.apache.org/jira/browse/DAEMON Or subscribe to the commons-user mailing list (prefix emails by [daemon]) http://commons.apache.org/mail-lists.html The Apache Commons Daemon Team commons-daemon-1.1.0-native-src/NOTICE.txt 0100664 0001750 0001750 00000000257 13130042551 020527 0 ustar 00mark mark 0000000 0000000 Apache Commons Daemon Copyright 1999-2017 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). commons-daemon-1.1.0-native-src/README 0100664 0001750 0001750 00000000427 11663511062 017673 0 ustar 00mark mark 0000000 0000000 Apache Commons Daemon ===================== Apache Commons Daemon is a set of utilities and Java support classes for running Java applications as server processes. Commonly known as 'daemon' processes in Unix terminology (hence the name), on Windows they are called 'services'. commons-daemon-1.1.0-native-src/unix/ 0040775 0001750 0001750 00000000000 13203026456 017776 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/unix/man/ 0040775 0001750 0001750 00000000000 13203026365 020550 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/unix/native/ 0040775 0001750 0001750 00000000000 13203026365 021263 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/unix/support/ 0040775 0001750 0001750 00000000000 13203026365 021511 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/unix/configure.in 0100664 0001750 0001750 00000011761 13017110374 022306 0 ustar 00mark mark 0000000 0000000 dnl dnl Licensed to the Apache Software Foundation (ASF) under one or more dnl contributor license agreements. See the NOTICE file distributed with dnl this work for additional information regarding copyright ownership. dnl The ASF licenses this file to You under the Apache License, Version 2.0 dnl (the "License"); you may not use this file except in compliance with dnl the License. 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@eng.sun.com> dnl Version $Id: configure.in 1771804 2016-11-28 20:18:04Z markt $ 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 Generate ./config.nice for reproducing runs of configure dnl AP_CONFIG_NICE(config.nice) 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, :) AC_CHECK_TOOL(STRIP, strip, :) 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 -x /usr/libexec/java_home then JAVA_HOME="`/usr/libexec/java_home 2>dev/null`" fi 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 INCLUDES="$INCLUDES -I`/bin/pwd -P`" cd $_prevdir unset _prevdir fi dnl ------------------------------------------------------------------------- dnl Check JAVA environment dnl ------------------------------------------------------------------------- AP_MSG_HEADER([Java compilation tools]) AP_FIND_JAVA() dnl MAC OS X does not used include but Headers if test -d $JAVA_HOME/Headers then JAVA_INC=Headers else JAVA_INC=include fi AP_FIND_JAVA_OS() if test -z "${JAVA_OS}" then AC_MSG_RESULT([jni_md.h found in $JAVA_HOME/$JAVA_INC]) INCLUDES="$INCLUDES -I$JAVA_HOME/include -I$JAVA_HOME/$JAVA_INC" else INCLUDES="$INCLUDES -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) if test "$supported_os" = "linux" then AC_CHECK_HEADER([sys/capability.h], [CFLAGS="$CFLAGS -DHAVE_LIBCAP"], AC_MSG_WARN([cannot find headers for libcap])) fi if test -z "$STRIPFLAGS" then STRIP="@: " else STRIP="$STRIP $STRIPFLAGS" fi AC_SUBST(INCLUDES) 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"]) commons-daemon-1.1.0-native-src/unix/INSTALL.txt 0100664 0001750 0001750 00000005052 13017110374 021640 0 ustar 00mark mark 0000000 0000000 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 from 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 Note: On Mac OS X <dir> is /System/Library/Frameworks/JavaVM.framework/Home. Depending on your JDK layout, configure might fail to find the JNI machine dependant include file (jni_md.h). If that's the case use the --with-os-type=<subdir> parameter where subdir points to the directory within JDK include directory containing jni_md.h file. 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!). Making 64-bit binaries To be able to build the 64-binaries for supported platforms enter the specific parameters before calling configure export CFLAGS=-m64 export LDFLAGS=-m64 ./configure make Making Universal binaries Some platforms like Mac OSX allow universal or fat binaries that allow both 32 and 64 binaries inside the same executable. To be able to build the fat binaries enter the specific parameters before calling configure export CFLAGS="-arch i386 -arch x86_64" export LDFLAGS="-arch i386 -arch x86_64" ./configure make Optional Build flags Make process allows specifying additional compilation flags at compile time by using EXTRA_CFLAGS and EXTRA_LDFLAGS either as environment variables or defined along the make command line make EXTRA_CFLAGS="-march=i586" will cause -march=i586 to be added to the configure generated CFLAGS. The same applies to EXTRA_LDFLAGS which will be added at link stage. commons-daemon-1.1.0-native-src/unix/man/jsvc.1.xml 0100664 0001750 0001750 00000020656 13203026051 022374 0 ustar 00mark mark 0000000 0000000 <?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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. --> <!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'>15 Nov 2017</refmiscinfo> <refmiscinfo class='source'>Jsvc version 1.1.0</refmiscinfo> <refmiscinfo class='manual'>Apache Commons Daemon 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'>-client <replaceable>client JVM</replaceable></arg> <arg choice='opt'>-server <replaceable>server JVM</replaceable></arg> <arg choice='opt'>-classpath <replaceable>path</replaceable></arg> <arg choice='opt'>-cp <replaceable>path</replaceable></arg> <arg choice='opt'>-java-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'>-restarts <replaceable>max restart count</replaceable></arg> <arg choice='opt'>-umask <replaceable>mask</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>-client</option> client JVM</term> <listitem> <para>use a client Java Virtual Machine.</para> </listitem> </varlistentry> <varlistentry> <term><option>-server</option> server JVM</term> <listitem> <para>use a server 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>-java-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>-restarts</option> max restart count</term> <listitem> <para>maximum automatic restart count -1=infinite (default), 0=none, 1..(INT_MAX-1)=fixed count </para> </listitem> </varlistentry> <varlistentry> <term><option>-umask</option> mask</term> <listitem> <para>sets the file mode creation mask </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', or 'SYSLOG' to send output to the system log.</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', or 'SYSLOG' to send output to the system log.</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 Apache Commons Daemon project. Authors are Jean-Frederic Clere, Remy Maucherat, Yoav Shapira, Bill Barker, Mladen Turk. JSVC is released under the Apache License Version 2.0.</para> </refsect1> </refentry> commons-daemon-1.1.0-native-src/unix/man/README 0100664 0001750 0001750 00000001175 11511404362 021426 0 ustar 00mark mark 0000000 0000000 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. commons-daemon-1.1.0-native-src/unix/native/debug.c 0100664 0001750 0001750 00000004577 13130043172 022521 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "jsvc.h" #include <sys/types.h> #include <unistd.h> #include <time.h> /* Wether debug is enabled or not */ bool log_debug_flag = false; /* Wether SYSLOG logging (for stderr) is enable or not. */ bool log_stderr_syslog_flag = false; /* Wether SYSLOG logging (for stdout) is enable or not. */ bool log_stdout_syslog_flag = false; /* The name of the jsvc binary. */ char *log_prog = "jsvc"; /* Dump a debug trace 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), "%Y-%m-%d %T", nowtm); va_start(ap, fmt); if (log_stderr_syslog_flag) fprintf(stderr, "%s %d %s debug: ", buff, getpid(), log_prog); #if defined(DEBUG) || defined(_DEBUG) else fprintf(stderr, "[debug] %s %d ", buff, getpid()); #endif 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; va_start(ap, fmt); if (log_stderr_syslog_flag) { now = time(NULL); nowtm = localtime(&now); strftime(buff, sizeof(buff), "%Y-%m-%d %T", nowtm); fprintf(stderr, "%s %d %s error: ", buff, getpid(), log_prog); } vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); fflush(stderr); va_end(ap); } commons-daemon-1.1.0-native-src/unix/native/.indent.pro 0100664 0001750 0001750 00000000157 11346135062 023345 0 ustar 00mark mark 0000000 0000000 -i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1 -nut -ncs -Tbool -Targ_data -Thome_data -Thome_jvm -Tdso_handle commons-daemon-1.1.0-native-src/unix/native/locks.h 0100664 0001750 0001750 00000002643 13130043172 022543 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __JSVC_LOCKS_H__ #define __JSVC_LOCKS_H__ /* * as Cygwin does not support locks, jsvc use NT API to emulate them. */ #ifdef OS_CYGWIN #define F_ULOCK 0 /* Unlock a previously locked region */ #define F_LOCK 1 /* Lock a region for exclusive use */ /* * allow a file to be locked * @param fildes an open file descriptor * @param function a control value that specifies the action to be taken * @param size number of bytes to lock * @return Zero on success, a value less than 0 if an error was encountered */ int lockf(int fildes, int function, off_t size); #endif #endif /* __JSVC_LOCKS_H__ */ commons-daemon-1.1.0-native-src/unix/native/help.c 0100664 0001750 0001750 00000014733 13203026001 022347 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "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(" -help | --help | -?\n"); printf(" show this help page (implies -nodetach)\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(" -client\n"); printf(" use a client Java Virtual Machine.\n"); printf(" -server\n"); printf(" use a server Java Virtual Machine.\n"); printf(" -cp | -classpath <directories and zip/jar files>\n"); printf(" set search path for service classes and resouces\n"); printf(" -java-home | -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(" -showversion\n"); printf(" show the current Java environment version (to check\n"); printf(" correctness of -home and -jvm) and continue execution.\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(" -cwd </full/path>\n"); printf(" set working directory to given location (defaults to /)\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(" -ea[:<packagename>...|:<classname>]\n"); printf(" -enableassertions[:<packagename>...|:<classname>]\n"); printf(" enable assertions\n"); printf(" -da[:<packagename>...|:<classname>]\n"); printf(" -disableassertions[:<packagename>...|:<classname>]\n"); printf(" disable assertions\n"); printf(" -esa | -enablesystemassertions\n"); printf(" enable system assertions\n"); printf(" -dsa | -disablesystemassertions\n"); printf(" disable system assertions\n"); printf(" -agentlib:<libname>[=<options>]\n"); printf(" load native agent library <libname>, e.g. -agentlib:hprof\n"); printf(" -agentpath:<pathname>[=<options>]\n"); printf(" load native agent library by full pathname\n"); printf(" -javaagent:<jarpath>[=<options>]\n"); printf(" load Java programming language agent, see java.lang.instrument\n"); printf(" -procname <procname>\n"); printf(" use the specified process name\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(" -restarts <maxrestarts>\n"); printf(" maximum automatic restarts (integer)\n"); printf(" -1=infinite (default), 0=none, 1..(INT_MAX-1)=fixed restart count\n"); printf(" -stop\n"); printf(" stop the service using the file given in the -pidfile option\n"); printf(" -keepstdin\n"); printf(" does not redirect stdin to /dev/null\n"); printf(" --add-modules=<module name>\n"); printf(" Java 9 --add-modules option. Passed as it is to JVM\n"); printf(" --module-path=<module path>\n"); printf(" Java 9 --module-path option. Passed as it is to JVM\n"); printf(" --upgrade-module-path=<module path>\n"); printf(" Java 9 --upgrade-module-path option. Passed as it is to JVM\n"); printf(" --add-reads=<module name>\n"); printf(" Java 9 --add-reads option. Passed as it is to JVM\n"); printf(" --add-exports=<module name>\n"); printf(" Java 9 --add-exports option. Passed as it is to JVM\n"); printf(" --add-opens=<module name>\n"); printf(" Java 9 --add-opens option. Passed as it is to JVM\n"); printf(" --limit-modules=<module name>\n"); printf(" Java 9 --limit-modules option. Passed as it is to JVM\n"); printf(" --patch-module=<module name>\n"); printf(" Java 9 --patch-module option. Passed as it is to JVM\n"); printf(" --illegal-access=<value>\n"); printf(" Java 9 --illegal-access option. Passed as it is to JVM. Refer java help for possible values.\n"); printf("\njsvc (Apache Commons Daemon) " JSVC_VERSION_STRING "\n"); printf("Copyright (c) 1999-2017 Apache Software Foundation.\n"); printf("\n"); } commons-daemon-1.1.0-native-src/unix/native/replace.c 0100664 0001750 0001750 00000007064 13130043172 023040 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "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; } commons-daemon-1.1.0-native-src/unix/native/java.c 0100664 0001750 0001750 00000042751 13176710431 022361 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "jsvc.h" #ifdef OS_CYGWIN typedef long long __int64; #endif #include <unistd.h> #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(); } static void failed(JNIEnv *env, jobject source, jstring message) { if (message) { const char *msg = (*env)->GetStringUTFChars(env, message, NULL); log_error("Failed %s", msg ? msg : "(null)"); if (msg) (*env)->ReleaseStringUTFChars(env, message, msg); } else log_error("Failed requested"); main_shutdown(); } /* Automatically restart when the JVM crashes */ static void java_abort123(void) { 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; } typedef jint (*jvm_create_t)(JavaVM **, JNIEnv **, JavaVMInitArgs *); bool java_signal(void) { jmethodID method; jboolean ret; char start[] = "signal"; char startparams[] = "()Z"; jsvc_xlate_to_ascii(start); jsvc_xlate_to_ascii(startparams); method = (*env)->GetStaticMethodID(env, cls, start, startparams); if (method == NULL) { (*env)->ExceptionClear(env); log_error("Cannot find DaemonLoader \"signal\" method"); return false; } ret = (*env)->CallStaticBooleanMethod(env, cls, method); /* Clear any pending exception * so we can continue calling native methods */ (*env)->ExceptionClear(env); log_debug("Daemon signal method returned %s", ret ? "true" : "false"); return ret; } /* 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 */ jvm_create_t symb = NULL; JNINativeMethod nativemethods[2]; JavaVMOption *opt = NULL; dso_handle libh = NULL; JavaVMInitArgs arg; char *libf = NULL; jint ret; int x; char loaderclass[] = LOADER; char shutdownmethod[] = "shutdown"; char shutdownparams[] = "(Z)V"; char failedmethod[] = "failed"; char failedparams[] = "(Ljava/lang/String;)V"; char daemonprocid[64]; /* 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) 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. - JVM 1.6, the library name is libverify.dylib - JVM 1.7 onwards, the library name is libjli.dylib */ if (replace(appf, 1024, "$JAVA_HOME/../Libraries/libverify.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/../MacOS/libjli.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) /* BS2000 does not allow to call JNI_CreateJavaVM indirectly */ #else symb = (jvm_create_t)dso_symbol(libh, "JNI_CreateJavaVM"); if (symb == NULL) { #ifdef OS_DARWIN symb = (jvm_create_t)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 */ /* Minimum Java version is Java 6 */ arg.version = JNI_VERSION_1_6; #if defined(OSD_POSIX) if (JNI_GetDefaultJavaVMInitArgs(&arg) < 0) { log_error("Cannot init default JVM default args"); return false; } #endif arg.ignoreUnrecognized = FALSE; arg.nOptions = args->onum + 4; /* pid, ppid and abort */ 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; } /* Add our daemon process id */ snprintf(daemonprocid, sizeof(daemonprocid), "-Dcommons.daemon.process.id=%d", (int)getpid()); opt[x].optionString = strdup(daemonprocid); jsvc_xlate_to_ascii(opt[x].optionString); opt[x++].extraInfo = NULL; snprintf(daemonprocid, sizeof(daemonprocid), "-Dcommons.daemon.process.parent=%d", (int)getppid()); opt[x].optionString = strdup(daemonprocid); jsvc_xlate_to_ascii(opt[x].optionString); opt[x++].extraInfo = NULL; snprintf(daemonprocid, sizeof(daemonprocid), "-Dcommons.daemon.version=%s", JSVC_VERSION_STRING); opt[x].optionString = strdup(daemonprocid); 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 = (void *)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", args->onum); 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("+-------------------------------------------------------"); log_debug("| Internal options: %d", arg.nOptions - args->onum); for (; x < arg.nOptions; 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) 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); jsvc_xlate_to_ascii(shutdownmethod); nativemethods[0].name = shutdownmethod; jsvc_xlate_to_ascii(shutdownparams); nativemethods[0].signature = shutdownparams; nativemethods[0].fnPtr = (void *)shutdown; jsvc_xlate_to_ascii(failedmethod); nativemethods[1].name = failedmethod; jsvc_xlate_to_ascii(failedparams); nativemethods[1].signature = failedparams; nativemethods[1].fnPtr = (void *)failed; if ((*env)->RegisterNatives(env, cls, nativemethods, 2) != 0) { log_error("Cannot register native methods"); return false; } log_debug("Native methods registered"); 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); 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]); if (currentArgument == NULL) { jsvc_xlate_from_ascii(args->args[x]); 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[] = "()V"; 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; } commons-daemon-1.1.0-native-src/unix/native/replace.h 0100664 0001750 0001750 00000003256 13130043172 023044 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __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__ */ commons-daemon-1.1.0-native-src/unix/native/help.h 0100664 0001750 0001750 00000001614 13130043172 022355 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __JSVC_HELP_H__ #define __JSVC_HELP_H__ void help(home_data *data); #endif /* __JSVC_HELP_H__ */ commons-daemon-1.1.0-native-src/unix/native/signals.c 0100664 0001750 0001750 00000006022 13130043172 023056 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ /* * as Windows does not support signal, jsvc uses events 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) (void) = 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) (void)) { 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 = 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; } #else const char __unused_signals_c[] = __FILE__; #endif commons-daemon-1.1.0-native-src/unix/native/jsvc-unix.c 0100664 0001750 0001750 00000114105 13203025072 023346 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "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 <string.h> #include <pwd.h> #include <grp.h> #include <syslog.h> #include <errno.h> #ifdef OS_LINUX #include <sys/prctl.h> #include <sys/syscall.h> #define _LINUX_FS_H #include <linux/capability.h> #ifdef HAVE_LIBCAP #include <sys/capability.h> #endif #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 controller_pid = 0; /* The parent process pid */ pid_t controlled = 0; /* the child process pid */ pid_t logger_pid = 0; /* the logger process pid */ static volatile bool stopping = false; static volatile bool doreload = false; static bool doreopen = false; static bool dosignal = false; static int run_controller(arg_data *args, home_data *data, uid_t uid, gid_t gid); static void set_output(char *outfile, char *errfile, bool redirectstdin, char *procname); #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; /* Ensure the controller knows a shutdown was requested. */ kill(controller_pid,sig); } break; case SIGINT: log_debug("Caught SIGINT: Scheduling a shutdown"); if (stopping == true) { log_error("Shutdown or reload already scheduled"); } else { stopping = true; /* Ensure the controller knows a shutdown was requested. */ kill(controller_pid,sig); } 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; case SIGUSR1: log_debug("Caught SIGUSR1: Reopening logs"); doreopen = true; break; case SIGUSR2: log_debug("Caught SIGUSR2: Scheduling a custom signal"); dosignal = true; break; default: log_debug("Caught unknown signal %d", sig); break; } } /* user and group */ static int set_user_group(const 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 LEGACY_CAPSALL (1 << CAP_NET_BIND_SERVICE) + \ (1 << CAP_SETUID) + \ (1 << CAP_SETGID) + \ (1 << CAP_DAC_READ_SEARCH) + \ (1 << CAP_DAC_OVERRIDE) #define LEGACY_CAPSMAX (1 << CAP_NET_BIND_SERVICE) + \ (1 << CAP_DAC_READ_SEARCH) + \ (1 << CAP_DAC_OVERRIDE) /* That a more reasonable configuration */ #define LEGACY_CAPS (1 << CAP_NET_BIND_SERVICE) + \ (1 << CAP_DAC_READ_SEARCH) + \ (1 << CAP_SETUID) + \ (1 << CAP_SETGID) /* probably the only one Java could use */ #define LEGACY_CAPSMIN (1 << CAP_NET_BIND_SERVICE) + \ (1 << CAP_DAC_READ_SEARCH) #define LEGACY_CAP_VERSION 0x19980330 static int set_legacy_caps(int caps) { struct __user_cap_header_struct caphead; struct __user_cap_data_struct cap; memset(&caphead, 0, sizeof caphead); caphead.version = LEGACY_CAP_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("set_caps: failed to set capabilities"); log_error("check that your kernel supports capabilities"); return -1; } return 0; } #ifdef HAVE_LIBCAP static cap_value_t caps_std[] = { CAP_NET_BIND_SERVICE, CAP_SETUID, CAP_SETGID, CAP_DAC_READ_SEARCH }; static cap_value_t caps_min[] = { CAP_NET_BIND_SERVICE, CAP_DAC_READ_SEARCH }; #define CAPS 1 #define CAPSMIN 2 typedef int (*fd_cap_free)(void *); typedef cap_t (*fd_cap_init)(void); typedef int (*fd_cap_clear)(cap_t); typedef int (*fd_cap_get_flag)(cap_t, cap_value_t, cap_flag_t, cap_flag_value_t *); typedef int (*fd_cap_set_flag)(cap_t, cap_flag_t, int, const cap_value_t *, cap_flag_value_t); typedef int (*fd_cap_set_proc)(cap_t); static dso_handle hlibcap = NULL; static fd_cap_free fp_cap_free; static fd_cap_init fp_cap_init; static fd_cap_clear fp_cap_clear; static fd_cap_get_flag fp_cap_get_flag; static fd_cap_set_flag fp_cap_set_flag; static fd_cap_set_proc fp_cap_set_proc; static const char *libcap_locs[] = { #ifdef __LP64__ "/lib64/libcap.so.2", "/lib64/libcap.so.1", "/lib64/libcap.so", "/usr/lib64/libcap.so.2", "/usr/lib64/libcap.so.1", "/usr/lib64/libcap.so", #endif "/lib/libcap.so.2", "/lib/libcap.so.1", "/lib/libcap.so", "/usr/lib/libcap.so.2", "/usr/lib/libcap.so.1", "/usr/lib/libcap.so", "libcap.so.2", "libcap.so.1", "libcap.so", NULL }; static int ld_libcap(void) { int i = 0; dso_handle dso = NULL; #define CAP_LDD(name) \ if ((fp_##name = dso_symbol(dso, #name)) == NULL) { \ log_error("cannot locate " #name " in libcap.so -- %s", dso_error()); \ dso_unlink(dso); \ return -1; \ } else log_debug("loaded " #name " from libcap.") if (hlibcap != NULL) return 0; while (libcap_locs[i] && dso == NULL) { if ((dso = dso_link(libcap_locs[i++]))) break; }; if (dso == NULL) { log_error("failed loading capabilities library -- %s.", dso_error()); return -1; } CAP_LDD(cap_free); CAP_LDD(cap_init); CAP_LDD(cap_clear); CAP_LDD(cap_get_flag); CAP_LDD(cap_set_flag); CAP_LDD(cap_set_proc); hlibcap = dso; #undef CAP_LDD return 0; } static int set_caps(int cap_type) { cap_t c; int ncap; int flag = CAP_SET; cap_value_t *caps; const char *type; if (ld_libcap()) { return set_legacy_caps(cap_type); } if (cap_type == CAPS) { ncap = sizeof(caps_std)/sizeof(cap_value_t); caps = caps_std; type = "default"; } else if (cap_type == CAPSMIN) { ncap = sizeof(caps_min)/sizeof(cap_value_t); caps = caps_min; type = "min"; } else { ncap = sizeof(caps_min)/sizeof(cap_value_t); caps = caps_min; type = "null"; flag = CAP_CLEAR; } c = (*fp_cap_init)(); (*fp_cap_clear)(c); (*fp_cap_set_flag)(c, CAP_EFFECTIVE, ncap, caps, flag); (*fp_cap_set_flag)(c, CAP_INHERITABLE, ncap, caps, flag); (*fp_cap_set_flag)(c, CAP_PERMITTED, ncap, caps, flag); if ((*fp_cap_set_proc)(c) != 0) { log_error("failed setting %s capabilities.", type); return -1; } (*fp_cap_free)(c); if (cap_type == CAPS) log_debug("increased capability set."); else if (cap_type == CAPSMIN) log_debug("decreased capability set to min required."); else log_debug("dropped capabilities."); return 0; } #else /* !HAVE_LIBCAP */ /* CAPSALL is to allow to read/write at any location */ #define CAPSALL LEGACY_CAPSALL #define CAPSMAX LEGACY_CAPSMAX #define CAPS LEGACY_CAPS #define CAPSMIN LEGACY_CAPSMIN static int set_caps(int caps) { return set_legacy_caps(caps); } #endif static int linuxset_user_group(const char *user, int uid, int gid) { int caps_set = 0; if (user == NULL) return 0; /* set capabilities enough for binding port 80 setuid/getuid */ if (getuid() == 0) { if (set_caps(CAPS) != 0) { if (getuid() != uid) { log_error("set_caps(CAPS) failed for user '%s'", user); return -1; } log_debug("set_caps(CAPS) failed for user '%s'", user); } /* make sure they are kept after setuid */ if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) { log_error("prctl failed in for user '%s'", user); return -1; } caps_set = 1; } /* set setuid/getuid */ if (set_user_group(user, uid, gid) != 0) { log_error("set_user_group failed for user '%s'", user); return -1; } if (caps_set) { /* set capability to binding port 80 read conf */ if (set_caps(CAPSMIN) != 0) { if (getuid() != uid) { log_error("set_caps(CAPSMIN) failed for user '%s'", user); return -1; } log_debug("set_caps(CAPSMIN) failed for user '%s'", user); } } 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) { /* Just wait */ } /* 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(void) { raise(SIGTERM); } #endif static void controller(int sig, siginfo_t *sip, void *ucp) { switch (sig) { case SIGTERM: case SIGINT: if (!stopping) { /* * Only forward a signal that requests shutdown once (the * issue being that the child also forwards the signal to * the parent and we need to avoid loops). * * Note that there are * two * instances of the stopping * variable ... one in the parent and the second in the * child. */ stopping = true; if (sip == NULL || !(sip->si_code <= 0 && sip->si_pid == controlled)) { log_debug("Forwarding signal %d to process %d", sig, controlled); kill(controlled, sig); } } break; case SIGHUP: case SIGUSR1: case SIGUSR2: log_debug("Forwarding signal %d to process %d", sig, controlled); kill(controlled, sig); break; default: log_debug("Caught unknown signal %d", sig); break; } } static int mkdir0(const char *name, int perms) { if (mkdir(name, perms) == 0) return 0; else return errno; } static int mkdir1(char *name, int perms) { int rc; rc = mkdir0(name, perms); if (rc == EEXIST) return 0; if (rc == ENOENT) { /* Missing an intermediate dir */ char *pos; if ((pos = strrchr(name, '/'))) { *pos = '\0'; if (*name) { if (!(rc = mkdir1(name, perms))) { /* Try again, now with parents created */ *pos = '/'; rc = mkdir0(name, perms); } } *pos = '/'; } } return rc; } static int mkdir2(const char *name, int perms) { int rc = 0; char *pos; char *dir = strdup(name); if (!dir) return ENOMEM; if ((pos = strrchr(dir, '/'))) { *pos = '\0'; if (*dir) rc = mkdir1(dir, perms); } free(dir); return rc; } /* * 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; int once = 0; /* skip writing the pid file if version or check */ if (args->vers || args->chck) { return 0; } retry: fd = open(args->pidf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { if (once == 0 && (errno == ENOTDIR || errno == ENOENT)) { once = 1; if (mkdir2(args->pidf, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH) == 0) goto retry; } 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; } } lseek(fd, SEEK_SET, 0); pidf = fdopen(fd, "r+"); fprintf(pidf, "%d\n", (int)getpid()); fflush(pidf); fclose(pidf); lockf(fd, F_ULOCK, 0); close(fd); } return 0; } /* * Delete the pid file */ static void remove_pid_file(arg_data *args, int pidn) { char buff[80]; int fd, i, pid; fd = open(args->pidf, O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); log_debug("remove_pid_file: open %s: fd=%d", args->pidf, fd); if (fd < 0) { return; } lockf(fd, F_LOCK, 0); i = read(fd, buff, sizeof(buff)); if (i > 0) { buff[i] = '\0'; pid = atoi(buff); } else { pid = -1; } if (pid == pidn) { /* delete the file while it's still locked */ unlink(args->pidf); } else { log_debug("remove_pid_file: pid changed (%d->%d), not removing pid file %s", pidn, pid, args->pidf); } lockf(fd, F_ULOCK, 0); close(fd); } /* * read the pid from the pidfile */ static int get_pidf(arg_data *args, bool quiet) { int fd; int i; char buff[80]; fd = open(args->pidf, O_RDONLY, 0); if (!quiet) log_debug("get_pidf: %d in %s", fd, args->pidf); if (fd < 0) { /* something has gone wrong the JVM has stopped */ return -1; } 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 (!quiet) 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 child is the controler process. * 2 - to start the JVM in the child 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, false); 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 == -1) 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 != -1) 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) { /* something has gone wrong the JVM has stopped */ return 1; } 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--; } /* It takes more than the wait time to start, * something must be wrong */ return 1; } /* * stop the running jsvc */ static int stop_child(arg_data *args) { int pid = get_pidf(args, false); int count = 60; if (pid > 0) { /* kill the process and wait until the pidfile has been * removed by the controler */ kill(pid, SIGTERM); while (count > 0) { sleep(1); pid = get_pidf(args, true); if (pid <= 0) { /* JVM has stopped */ return 0; } count--; } } return -1; } /* * child process logic. */ static int child(arg_data *args, home_data *data, uid_t uid, gid_t gid) { int ret = 0; struct sigaction act; /* 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; } #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) { log_error("jsvc (Apache Commons Daemon) " JSVC_VERSION_STRING); log_error("Copyright (c) 1999-2011 Apache Software Foundation."); if (java_version() != true) { return -1; } else return 0; } /* Check wether we need to dump the VM version */ else if (args->vershow == true) { if (java_version() != true) { return 7; } } /* 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 (args->user && 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 */ if (java_start() != true) { log_debug("java_start failed"); return 5; } else log_debug("java_start done"); /* Install signal handlers */ memset(&act, '\0', sizeof(act)); act.sa_handler = handler; sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART | SA_NOCLDSTOP; sigaction(SIGHUP, &act, NULL); sigaction(SIGUSR1, &act, NULL); sigaction(SIGUSR2, &act, NULL); sigaction(SIGTERM, &act, NULL); sigaction(SIGINT, &act, NULL); log_debug("Waiting for a signal to be delivered"); create_tmp_file(args); while (!stopping) { #if defined(OSD_POSIX) java_sleep(60); /* pause(); */ #else /* pause() is not threadsafe */ sleep(60); #endif if(doreopen) { doreopen = false; set_output(args->outfile, args->errfile, args->redirectstdin, args->procname); } if(dosignal) { dosignal = false; java_signal(); } } 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; mkdir2(outfile, S_IRWXU); 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); } #define LOGBUF_SIZE 1024 /* Read from file descriptors. Log to syslog. */ static int logger_child(int out_fd, int err_fd, char *procname) { fd_set rfds; struct timeval tv; int retval, nfd = -1, rc = 0; ssize_t n; char buf[LOGBUF_SIZE]; if (out_fd == -1 && err_fd == -1) return EINVAL; if (out_fd == -1) nfd = err_fd; else if (err_fd == -1) nfd = out_fd; else nfd = out_fd > err_fd ? out_fd : err_fd; ++nfd; openlog(procname, LOG_PID, LOG_DAEMON); while (out_fd != -1 || err_fd != -1) { FD_ZERO(&rfds); if (out_fd != -1) { FD_SET(out_fd, &rfds); } if (err_fd != -1) { FD_SET(err_fd, &rfds); } tv.tv_sec = 60; tv.tv_usec = 0; retval = select(nfd, &rfds, NULL, NULL, &tv); if (retval == -1) { rc = errno; syslog(LOG_ERR, "select: %s", strerror(errno)); /* If select failed no point to continue */ break; } else if (retval) { if (out_fd != -1 && FD_ISSET(out_fd, &rfds)) { do { n = read(out_fd, buf, LOGBUF_SIZE-1); } while (n == -1 && errno == EINTR); if (n == -1) { syslog(LOG_ERR, "read: %s", strerror(errno)); close(out_fd); if (err_fd == -1) break; nfd = err_fd + 1; out_fd = -1; } else if (n > 0 && buf[0] != '\n') { buf[n] = 0; syslog(LOG_INFO, "%s", buf); } } if (err_fd != -1 && FD_ISSET(err_fd, &rfds)) { do { n = read(err_fd, buf, LOGBUF_SIZE-1); } while (n == -1 && errno == EINTR); if (n == -1) { syslog(LOG_ERR, "read: %s", strerror(errno)); close(err_fd); if (out_fd == -1) break; nfd = out_fd + 1; err_fd = -1; } else if (n > 0 && buf[0] != '\n') { buf[n] = 0; syslog(LOG_ERR, "%s", buf); } } } } return rc; } /** * Redirect stdin, stdout, stderr. */ static void set_output(char *outfile, char *errfile, bool redirectstdin, char *procname) { int out_pipe[2] = {-1, -1}; int err_pipe[2] = {-1, -1}; int fork_needed = 0; if (redirectstdin == true) { 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; if (strcmp(outfile, "&1") == 0 && strcmp(errfile, "&2") == 0) return; if (strcmp(outfile, "SYSLOG") == 0) { freopen("/dev/null", "a", stdout); /* Send stdout to syslog through a logger process */ if (pipe(out_pipe) == -1) { log_error("cannot create stdout pipe: %s", strerror(errno)); } else { fork_needed = 1; log_stdout_syslog_flag = true; } } else if (strcmp(outfile, "&2")) { if (strcmp(outfile, "&1")) { /* Redirect stdout to a file */ loc_freopen(outfile, "a", stdout); } } if (strcmp(errfile, "SYSLOG") == 0) { freopen("/dev/null", "a", stderr); /* Send stderr to syslog through a logger process */ if (pipe(err_pipe) == -1) { log_error("cannot create stderr pipe: %s", strerror(errno)); } else { fork_needed = 1; log_stderr_syslog_flag = true; } } else if (strcmp(errfile, "&1")) { if (strcmp(errfile, "&2")) { /* Redirect stderr to a file */ loc_freopen(errfile, "a", stderr); } } if (strcmp(errfile, "&1") == 0 && strcmp(outfile, "&1")) { /* * -errfile &1 -outfile foo * Redirect stderr to stdout */ close(2); dup2(1, 2); } if (strcmp(outfile, "&2") == 0 && strcmp(errfile, "&2")) { /* * -outfile &2 -errfile foo * Redirect stdout to stderr */ close(1); dup2(2, 1); } if (fork_needed) { pid_t pid = fork(); if (pid == -1) { log_error("cannot create logger process: %s", strerror(errno)); } else { if (pid != 0) { /* Parent process. * Close child pipe endpoints. */ logger_pid = pid; if (out_pipe[0] != -1) { close(out_pipe[0]); if (dup2(out_pipe[1], 1) == -1) { log_error("cannot redirect stdout to pipe for syslog: %s", strerror(errno)); } } if (err_pipe[0] != -1) { close(err_pipe[0]); if (dup2(err_pipe[1], 2) == -1) { log_error("cannot redirect stderr to pipe for syslog: %s", strerror(errno)); } } } else { exit(logger_child(out_pipe[0], err_pipe[0], procname)); } } } } int main(int argc, char *argv[]) { arg_data *args = NULL; home_data *data = NULL; pid_t pid = 0; uid_t uid = 0; gid_t gid = 0; int res; /* 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; /* We don't want to use a form of exec() that searches the * PATH, so require that argv[0] be either an absolute or * relative path. Error out if this isn't the case. */ tmp = strchr(argv[0], '/'); if (tmp == NULL) { log_error("JSVC re-exec requires execution with an absolute or relative path"); return 1; } /* * 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 } if (chdir(args->cwd)) { log_error("ERROR: jsvc was unable to " "change directory to: %s", args->cwd); } /* * umask() uses inverse logic; bits are CLEAR for allowed access. */ if (~args->umask & 0022) { log_error("NOTICE: jsvc umask of %03o allows " "write permission to group and/or other", args->umask); } envmask = umask(args->umask); set_output(args->outfile, args->errfile, args->redirectstdin, args->procname); log_debug("Switching umask back to %03o from %03o", envmask, args->umask); res = run_controller(args, data, uid, gid); if (logger_pid != 0) { kill(logger_pid, SIGTERM); } return res; } static int run_controller(arg_data *args, home_data *data, uid_t uid, gid_t gid) { pid_t pid = 0; int restarts = 0; struct sigaction act; controller_pid = getpid(); /* * Install signal handlers for the parent process. * These will be replaced in the child process. */ memset(&act, '\0', sizeof(act)); act.sa_handler = controller; sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART | SA_NOCLDSTOP | SA_SIGINFO; sigaction(SIGHUP, &act, NULL); sigaction(SIGUSR1, &act, NULL); sigaction(SIGUSR2, &act, NULL); sigaction(SIGTERM, &act, NULL); sigaction(SIGINT, &act, NULL); /* We have to fork: this process will become the controller and the other will be the child */ while ((pid = fork()) != -1) { time_t laststart; int status = 0; /* 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 while (waitpid(pid, &status, 0) != pid) { /* Wait for process */ } /* 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) remove_pid_file(args, pid); /* 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 (!stopping) { if (status == 123) { if (args->restarts == 0) { log_debug("Service failure, restarts disabled"); return 1; } if (args->restarts != -1 && args->restarts <= restarts) { log_debug("Service failure, restart limit reached, aborting"); return 1; } log_debug("Reloading service"); restarts++; /* 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 (!stopping) { if (laststart + 60 > time(NULL)) { log_debug("Waiting 60 s to prevent looping"); sleep(60); } /* Normal or user controlled termination, reset restart counter */ restarts = 0; 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); } commons-daemon-1.1.0-native-src/unix/native/location.h 0100664 0001750 0001750 00000002033 13130043172 023231 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __JSVC_LOCATION_H__ #define __JSVC_LOCATION_H__ #include "jsvc.h" extern char *location_home[]; extern char *location_jvm_cfg[]; extern char *location_jvm_default[]; extern char *location_jvm_configured[]; #endif /* __JSVC_LOCATION_H__ */ commons-daemon-1.1.0-native-src/unix/native/locks.c 0100664 0001750 0001750 00000002602 13130043172 022531 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ /* * as Cygwin does not support lockf, jsvc uses fcntl to emulate it. */ #ifdef OS_CYGWIN #include "jsvc.h" #include <sys/fcntl.h> /* * File locking routine */ 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); } #else const char __unused_locks_c[] = __FILE__; #endif commons-daemon-1.1.0-native-src/unix/native/home.h 0100664 0001750 0001750 00000002600 13130043172 022351 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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 __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__ */ commons-daemon-1.1.0-native-src/unix/native/debug.h 0100664 0001750 0001750 00000003347 13130043172 022520 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __JSVC_DEBUG_H__ #define __JSVC_DEBUG_H__ #ifdef __cplusplus extern "C" { #endif /** * Wether debugging is enabled or not. */ extern bool log_debug_flag; /* Wether SYSLOG logging (for stderr) is enable or not. */ extern bool log_stderr_syslog_flag; /* Wether SYSLOG logging (for stdout) is enable or not. */ extern bool log_stdout_syslog_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__ */ commons-daemon-1.1.0-native-src/unix/native/java.h 0100664 0001750 0001750 00000002353 13130043172 022347 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __JSVC_JAVA_H__ #define __JSVC_JAVA_H__ #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_signal(void); bool java_start(void); bool java_stop(void); bool java_version(void); bool java_check(arg_data *args); bool JVM_destroy(int exit); #endif /* __JSVC_JAVA_H__ */ commons-daemon-1.1.0-native-src/unix/native/version.h 0100664 0001750 0001750 00000004043 13203026321 023107 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __VERSION_H__ #define __VERSION_H__ /** * Major API changes that could cause compatibility problems for older * programs such as structure size changes. No binary compatibility is * possible across a change in the major version. */ #define JSVC_MAJOR_VERSION 1 /** * Minor API changes that do not cause binary compatibility problems. * Should be reset to 0 when upgrading JSVC_MAJOR_VERSION */ #define JSVC_MINOR_VERSION 1 /** patch level */ #define JSVC_PATCH_VERSION 0 /** * This symbol is defined for internal, "development" copies of JSVC. * This symbol will be #undef'd for releases. */ #define JSVC_IS_DEV_VERSION 0 /** Properly quote a value as a string in the C preprocessor */ #define JSVC_STRINGIFY(n) JSVC_STRINGIFY_HELPER(n) /** Helper macro for JSVC_STRINGIFY */ #define JSVC_STRINGIFY_HELPER(n) #n /** The formatted string of APU's version */ #define JSVC_VERSION_STRING \ JSVC_STRINGIFY(JSVC_MAJOR_VERSION) "." \ JSVC_STRINGIFY(JSVC_MINOR_VERSION) "." \ JSVC_STRINGIFY(JSVC_PATCH_VERSION) \ JSVC_IS_DEV_STRING /** Internal: string form of the "is dev" flag */ #if JSVC_IS_DEV_VERSION #define JSVC_IS_DEV_STRING "-dev" #else #define JSVC_IS_DEV_STRING "" #endif #endif /* __VERSION_H__ */ commons-daemon-1.1.0-native-src/unix/native/arguments.h 0100664 0001750 0001750 00000005662 13176614454 023462 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __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; /** Working directory (defaults to /). */ char *cwd; /** 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; /** Show the VM version and continue. */ bool vershow; /** 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; /** max restarts **/ int restarts; /** 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 **/ char *procname; /** Whether to redirect stdin to /dev/null or not. Defaults to true **/ bool redirectstdin; /** What umask to use **/ int umask; } 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__ */ commons-daemon-1.1.0-native-src/unix/native/dso.h 0100664 0001750 0001750 00000002305 13130043172 022210 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __JSVC_DSO_H__ #define __JSVC_DSO_H__ #include "jsvc.h" /** * A library handle represents a unique pointer to its location in memory. */ #ifdef DSO_DYLD #include <mach-o/dyld.h> #endif 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); char *dso_error(void); #endif /* __JSVC_DSO_H__ */ commons-daemon-1.1.0-native-src/unix/native/home.c 0100664 0001750 0001750 00000020110 13172347221 022350 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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 "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; } } } fclose(cfgf); 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 || *path == '\0' || strcmp(path, "/") == 0) { log_debug("Home not specified on command line, using environment"); path = getenv("JAVA_HOME"); if (path == NULL || *path == '\0' || strcmp(path, "/") == 0) { /* guard against empty JAVA_HOME */ path = NULL; } } 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); } commons-daemon-1.1.0-native-src/unix/native/Makefile.in 0100664 0001750 0001750 00000002322 13130530533 023320 0 ustar 00mark mark 0000000 0000000 # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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 ../Makedefs OBJS = arguments.o \ debug.o \ dso-dlfcn.o \ dso-dyld.o \ help.o \ home.o \ java.o \ location.o \ replace.o \ locks.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) $(EXTRA_LDFLAGS) jsvc-unix.o libservice.a $(LIBS) -o ../jsvc $(STRIP) ../jsvc clean: rm -f $(OBJS) ../jsvc jsvc-unix.o libservice.a commons-daemon-1.1.0-native-src/unix/native/location.c 0100664 0001750 0001750 00000016362 13174063766 023261 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "jsvc.h" /* Locations of various JVM files. We have to deal with all this madness since * we're not distributed together (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-dependent) * 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) || defined(OS_AIX) "/usr/java/default", "/usr/java", "/usr/local/java", "/usr/lib/jvm/default-java", "/usr/lib/jvm/java", "/etc/alternatives/java_sdk", "/etc/alternatives/java_sdk_openjdk", "/etc/alternatives/jre", #if defined(__LP64__) "/lib64/jvm/java", "/lib64/jvm/java-openjdk", #endif "/lib/jvm/java", "/lib/jvm/java-openjdk", #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/java6", "/opt/java1.5", "/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 */ #if defined(OS_AIX) "$JAVA_HOME/jre/lib/ppc/jvm.cfg", /* JDK */ "$JAVA_HOME/lib/ppc/jvm.cfg", /* JRE */ #endif 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", "$JAVA_HOME/jre/lib/server/libjvm.dylib", "$JAVA_HOME/jre/lib/client/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) || defined(OS_AIX) "$JAVA_HOME/jre/lib/" CPU "/classic/libjvm.so", /* Sun JDK 1.2 */ "$JAVA_HOME/jre/lib/" CPU "/server/libjvm.so", /* Sun JDK 1.4 */ "$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 "/server/libjvm.so", /* Sun JRE 1.4 */ "$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." SO_EXT, "$JAVA_HOME/jre/lib/" CPU "/client/libjvm." SO_EXT, "$JAVA_HOME/jre/lib/" CPU "/hotspot/libjvm." SO_EXT, "$JAVA_HOME/jre/lib/" CPU "/classic/libjvm." SO_EXT, #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/lib/$VM_NAME/libjvm.dylib", /* Java 9 */ "$JAVA_HOME/jre/lib/$VM_NAME/libjvm.dylib", "$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) || defined(OS_AIX) "$JAVA_HOME/lib/$VM_NAME/libjvm.so", /* Java 9 */ "$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 */ #if defined(OS_AIX) "$JAVA_HOME/jre/lib/ppc/$VM_NAME/libjvm.so", /* Sun JDK 1.3 */ "$JAVA_HOME/lib/ppc/$VM_NAME/libjvm.so", /* Sun JRE 1.3 */ #endif #elif defined(OS_HPUX) "$JAVA_HOME/jre/lib/" CPU "/$VM_NAME/libjvm." SO_EXT, "$JAVA_HOME/lib/" CPU "/$VM_NAME/libjvm." SO_EXT, #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, }; commons-daemon-1.1.0-native-src/unix/native/signals.h 0100664 0001750 0001750 00000002135 13130043172 023064 0 ustar 00mark mark 0000000 0000000 /* 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. */ #ifndef __JSVC_SIGNALS_H__ #define __JSVC_SIGNALS_H__ /* * as Windows does not support signal, jsvc use event to emulate them. * The supported signal is SIGTERM. */ #ifdef OS_CYGWIN /* * set a routine handler for the signal * note that it cannot be used to change the signal handler * @param func The function to call on termination * @return Zero on success, a value less than 0 if an error was encountered */ int SetTerm(void (*func) (void)); #endif #endif /* ifndef __JSVC_SIGNALS_H__ */ commons-daemon-1.1.0-native-src/unix/native/dso-dlfcn.c 0100664 0001750 0001750 00000003131 13130043172 023265 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "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(void) { 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(void) { return (dlerror()); } #endif /* ifdef DSO_DLFCN */ commons-daemon-1.1.0-native-src/unix/native/dso-dyld.c 0100664 0001750 0001750 00000010377 13130043172 023145 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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 "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 */ commons-daemon-1.1.0-native-src/unix/native/jsvc.h 0100664 0001750 0001750 00000002622 13130043172 022372 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 __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 */ #ifdef OS_DARWIN #include <stdbool.h> #else typedef enum { false, true } bool; #endif #include "version.h" #include "debug.h" #include "arguments.h" #include "home.h" #include "location.h" #include "replace.h" #include "dso.h" #include "java.h" #include "help.h" #include "signals.h" #include "locks.h" int main(int argc, char *argv[]); void main_reload(void); void main_shutdown(void); #endif /* ifndef __JSVC_H__ */ commons-daemon-1.1.0-native-src/unix/native/arguments.c 0100664 0001750 0001750 00000042204 13176614454 023446 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "jsvc.h" #include <limits.h> #include <glob.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]); } static char *memstrcat(char *ptr, const char *str, const char *add) { size_t nl = 1; int nas = ptr == NULL; if (ptr) nl += strlen(ptr); if (str) nl += strlen(str); if (add) nl += strlen(add); ptr = (char *)realloc(ptr, nl); if (ptr) { if (nas) *ptr = '\0'; if (str) strcat(ptr, str); if (add) strcat(ptr, add); } return ptr; } static char* eval_ppath(char *strcp, const char *pattern) { glob_t globbuf; char jars[PATH_MAX + 1]; if (strlen(pattern) > (sizeof(jars) - 5)) { return memstrcat(strcp, pattern, NULL); } strcpy(jars, pattern); strcat(jars, ".jar"); memset(&globbuf, 0, sizeof(glob_t)); if (glob(jars, GLOB_ERR, NULL, &globbuf) == 0) { size_t n; for (n = 0; n < globbuf.gl_pathc - 1; n++) { strcp = memstrcat(strcp, globbuf.gl_pathv[n], ":"); if (strcp == NULL) { globfree(&globbuf); return NULL; } } strcp = memstrcat(strcp, globbuf.gl_pathv[n], NULL); globfree(&globbuf); } return strcp; } #define JAVA_CLASSPATH "-Djava.class.path=" /** * Call glob on each PATH like string path. * Glob is called only if the part ends with asterisk in which * case asterisk is replaced by *.jar when searching */ static char* eval_cpath(const char *cp) { char *cpy = memstrcat(NULL, JAVA_CLASSPATH, cp); char *gcp = NULL; char *pos; char *ptr; if (!cpy) return NULL; ptr = cpy + sizeof(JAVA_CLASSPATH) - 1;; while ((pos = strchr(ptr, ':'))) { *pos = '\0'; if (gcp) gcp = memstrcat(gcp, ":", NULL); else gcp = memstrcat(NULL, JAVA_CLASSPATH, NULL); if ((pos > ptr) && (*(pos - 1) == '*')) { if (!(gcp = eval_ppath(gcp, ptr))) { /* Error. * Return the original string processed so far. */ return cpy; } } else gcp = memstrcat(gcp, ptr, NULL); ptr = pos + 1; } if (*ptr) { size_t end = strlen(ptr); if (gcp) gcp = memstrcat(gcp, ":", NULL); else gcp = memstrcat(NULL, JAVA_CLASSPATH, NULL); if (end > 0 && ptr[end - 1] == '*') { /* Last path elemet ends with star * Do a globbing. */ gcp = eval_ppath(gcp, ptr); } else { /* Just add the part */ gcp = memstrcat(gcp, ptr, NULL); } } /* Free the allocated copy */ if (gcp) { free(cpy); return gcp; } else return cpy; } /* Parse command line arguments */ static arg_data *parse(int argc, char *argv[]) { arg_data *args = NULL; char *temp = NULL; char *cmnd = NULL; 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->restarts = -1; /* Infinite restarts by default */ 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->clas = NULL; /* No class predefined */ args->anum = 0; /* Zero class specific arguments but make room*/ args->cwd = "/"; /* Use root as default */ args->outfile = "/dev/null"; /* Swallow by default */ args->errfile = "/dev/null"; /* Swallow by default */ args->redirectstdin = true; /* Redirect stdin to /dev/null by default */ args->procname = "jsvc.exec"; #ifndef JSVC_UMASK args->umask = 0077; #else args->umask = JSVC_UMASK; #endif if (!(args->args = (char **)malloc(argc * sizeof(char *)))) return NULL; if (!(args->opts = (char **)malloc(argc * sizeof(char *)))) return NULL; /* 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") || !strcmp(argv[x], "-classpath")) { temp = optional(argc, argv, x++); if (temp == NULL) { log_error("Invalid classpath specified"); return NULL; } args->opts[args->onum] = eval_cpath(temp); if (args->opts[args->onum] == NULL) { log_error("Invalid classpath specified"); return NULL; } free(temp); args->onum++; } else if (!strcmp(argv[x], "-jvm")) { args->name = optional(argc, argv, x++); if (args->name == NULL) { log_error("Invalid Java VM name specified"); return NULL; } } else if (!strcmp(argv[x], "-client")) { args->name = strdup("client"); } else if (!strcmp(argv[x], "-server")) { args->name = strdup("server"); } else if (!strcmp(argv[x], "-home") || !strcmp(argv[x], "-java-home")) { args->home = optional(argc, argv, x++); if (args->home == NULL) { log_error("Invalid Java Home specified"); return NULL; } } else if (!strcmp(argv[x], "-user")) { args->user = optional(argc, argv, x++); if (args->user == NULL) { log_error("Invalid user name specified"); return NULL; } } else if (!strcmp(argv[x], "-cwd")) { args->cwd = optional(argc, argv, x++); if (args->cwd == NULL) { log_error("Invalid working directory specified"); return NULL; } } else if (!strcmp(argv[x], "-version")) { args->vers = true; args->dtch = false; } else if (!strcmp(argv[x], "-showversion")) { args->vershow = true; } else if (!strcmp(argv[x], "-?") || !strcmp(argv[x], "-help") || !strcmp(argv[x], "--help")) { args->help = true; args->dtch = false; return args; } else if (!strcmp(argv[x], "-X")) { log_error("Option -X currently unsupported"); log_error("Please use \"java -X\" to see your extra VM options"); } else if (!strcmp(argv[x], "-debug")) { log_debug_flag = true; } else if (!strcmp(argv[x], "-wait")) { temp = optional(argc, argv, x++); if (temp) args->wait = atoi(temp); if (args->wait < 10) { log_error("Invalid wait time specified (min=10)"); return NULL; } } else if (!strcmp(argv[x], "-restarts")) { temp = optional(argc, argv, x++); if (temp) args->restarts = atoi(temp); if (args->restarts < -1) { log_error("Invalid max restarts [-1,0,...)"); return NULL; } } else if (!strcmp(argv[x], "-umask")) { temp = optional(argc, argv, x++); if (temp == NULL) { log_error("Invalid umask specified"); return NULL; } /* Parameter must be in octal */ args->umask = (int)strtol(temp, NULL, 8); if (args->umask < 02) { log_error("Invalid umask specified (min=02)"); return NULL; } } else if (!strcmp(argv[x], "-stop")) { args->stop = true; } else if (!strcmp(argv[x], "-check")) { args->chck = true; args->dtch = false; } else if (!strcmp(argv[x], "-nodetach")) { args->dtch = false; } else if (!strcmp(argv[x], "-keepstdin")) { args->redirectstdin = false; } else if (!strcmp(argv[x], "-service")) { args->service = true; } else if (!strcmp(argv[x], "-install")) { args->install = true; } else if (!strcmp(argv[x], "-remove")) { args->remove = true; } else if (!strcmp(argv[x], "-pidfile")) { args->pidf = optional(argc, argv, x++); if (args->pidf == NULL) { log_error("Invalid PID file specified"); return NULL; } } else if (!strcmp(argv[x], "-outfile")) { args->outfile = optional(argc, argv, x++); if(args->outfile == NULL) { log_error("Invalid Output File specified"); return NULL; } } else if (!strcmp(argv[x], "-errfile")) { args->errfile = optional(argc, argv, x++); if (args->errfile == NULL) { log_error("Invalid Error File specified"); return NULL; } } else if (!strncmp(argv[x], "-verbose", 8)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strcmp(argv[x], "-D")) { log_error("Parameter -D must be followed by <name>=<value>"); return NULL; } else if (!strncmp(argv[x], "-D", 2)) { temp = strchr(argv[x], '='); 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 (!strncmp(argv[x], "-X", 2)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "-ea", 3)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "-enableassertions", 17)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "-da", 3)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "-disableassertions", 18)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strcmp(argv[x], "-esa")) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strcmp(argv[x], "-enablesystemassertions")) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strcmp(argv[x], "-dsa")) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strcmp(argv[x], "-disablesystemassertions")) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strcmp(argv[x], "-procname")) { args->procname = optional(argc, argv, x++); if (args->procname == NULL) { log_error("Invalid process name specified"); return NULL; } } else if (!strncmp(argv[x], "-agentlib:", 10)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "-agentpath:", 11)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "-javaagent:", 11)) { args->opts[args->onum++] = strdup(argv[x]); } /* Java 9 specific options */ else if (!strncmp(argv[x], "--add-modules=", 14)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--module-path=", 14)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--upgrade-module-path=", 22)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--add-reads=", 12)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--add-exports=", 14)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--add-opens=", 12)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--limit-modules=", 16)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--patch-module=", 15)) { args->opts[args->onum++] = strdup(argv[x]); } else if (!strncmp(argv[x], "--illegal-access=", 17)) { args->opts[args->onum++] = strdup(argv[x]); } else if (*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 const char *IsYesNo(bool par) { switch (par) { case false: return "No"; case true: return "Yes"; } return "[Error]"; } static const char *IsTrueFalse(bool par) { switch (par) { case false: return "False"; case true: return "True"; } return "[Error]"; } static const 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) { 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("| Restarts: %d", args->restarts); 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; } commons-daemon-1.1.0-native-src/unix/Makedefs.in 0100664 0001750 0001750 00000002071 13130043172 022033 0 ustar 00mark mark 0000000 0000000 # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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@eng.sun.com> CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ INCLUDES = @INCLUDES@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ RANLIB = @RANLIB@ LDCMD = @LDCMD@ STRIP = @STRIP@ .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_CFLAGS) $(INCLUDES) -c $< -o $@ commons-daemon-1.1.0-native-src/unix/support/config.guess 0100664 0001750 0001750 00000125644 13010206346 024032 0 ustar 00mark mark 0000000 0000000 #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2016 Free Software Foundation, Inc. timestamp='2016-10-02' # 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 3 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, see <http://www.gnu.org/licenses/>. # # 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. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to <config-patches@gnu.org>. 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@gnu.org>." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2016 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 ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # 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 trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; 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 ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) 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 case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # 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 tuples: *-*-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. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ 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 # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; *:Sortix:*:*) echo ${UNAME_MACHINE}-unknown-sortix exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # 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. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; 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 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@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 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; 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 ;; 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 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /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 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # 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 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build 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 -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; 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 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????: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 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; 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 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include <sys/systemcfg.h> main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi 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 ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | 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/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 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]) 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 ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build 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 -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = hppa2.0w ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build 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 -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; 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 ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; 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 i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; k1om:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; mips64el:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; 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-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # 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. echo i386-sequent-sysv4 exit ;; 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 ;; 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 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; 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 ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; 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|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; 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 i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; 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 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*: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; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' 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; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *: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 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says <Richard.M.Bartel@ccMail.Census.GOV> echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; 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 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *: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 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; esac cat >&2 <<EOF $0: unable to guess system type This script (version $timestamp), has failed to recognize the operating system you are using. If your script is old, overwrite config.guess and config.sub with the latest versions from: http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess and http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub If $0 has already been updated, send the following data and any information you think might be pertinent to config-patches@gnu.org to provide the necessary 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: commons-daemon-1.1.0-native-src/unix/support/apsupport.m4 0100664 0001750 0001750 00000013413 13130530741 024004 0 ustar 00mark mark 0000000 0000000 dnl dnl Licensed to the Apache Software Foundation (ASF) under one or more dnl contributor license agreements. See the NOTICE file distributed with dnl this work for additional information regarding copyright ownership. dnl The ASF licenses this file to You under the Apache License, Version 2.0 dnl (the "License"); you may not use this file except in compliance with dnl the License. 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 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_DLFCN" 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" supported_os="sysv" ;; sysv4) CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN -Kthread" LDFLAGS="-Kthread $LDFLAGS" LIBS="$LIBS -ldl" supported_os="sysv4" ;; 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" supported_os="osf5" ;; hpux*) CFLAGS="$CFLAGS -DOS_HPUX -DDSO_DLFCN" supported_os="hp-ux" host_os="hpux" ;; aix5*) CFLAGS="$CFLAGS -DOS_AIX -DDSO_DLFCN" LDFLAGS="$LDFLAGS -ldl" supported_os="aix5" ;; kfreebsd*-gnu) CFLAGS="$CFLAGS -DOS_BSD -DDSO_DLFCN -pthread" supported_os="kfreebsd-gnu" LIBS="$LIBS -ldl -lpthread" ;; gnu*) CFLAGS="$CFLAGS -DOS_HURD -DDSO_DLFCN -pthread " supported_os="hurd-gnu" LIBS="$LIBS -ldl -lpthread" ;; *) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Unsupported operating system "$host_os"]) ;; esac case $host_cpu in powerpc64) CFLAGS="$CFLAGS -DCPU=\\\"ppc64\\\"" HOST_CPU=ppc64 ;; powerpc64le) CFLAGS="$CFLAGS -DCPU=\\\"ppc64le\\\"" HOST_CPU=ppc64le ;; powerpc*) CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\"" HOST_CPU=$host_cpu ;; sparc*) CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\"" HOST_CPU=$host_cpu ;; i?86|x86) CFLAGS="$CFLAGS -DCPU=\\\"i386\\\"" HOST_CPU=i386 ;; x86_64 | amd64) 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 | mipsn32 | mips64) CFLAGS="$CFLAGS -DCPU=\\\"mips\\\"" supported_os="mips" HOST_CPU=mips ;; alpha*) CFLAGS="$CFLAGS -DCPU=\\\"alpha\\\"" supported_os="alpha" HOST_CPU=alpha ;; hppa2.0w|hppa64) CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0W\\\" -DSO_EXT=\\\"sl\\\"" host_cpu=hppa2.0w HOST_CPU=PA_RISC2.0W ;; hppa2.0n|hppa32) CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0N\\\" -DSO_EXT=\\\"sl\\\"" HOST_CPU=PA_RISC2.0N ;; hppa2.0) if test "$host_os" = "hpux" then host_cpu=hppa2.0w HOST_CPU=PA_RISC2.0W else HOST_CPU=PA_RISC2.0 fi CFLAGS="$CFLAGS -DCPU=\\\"$HOST_CPU\\\" -DSO_EXT=\\\"sl\\\"" ;; mipsel | mipsn32el | mips64el) CFLAGS="$CFLAGS -DCPU=\\\"mipsel\\\"" supported_os="mipsel" HOST_CPU=mipsel ;; ia64w) CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\"" HOST_CPU=IA64W ;; ia64n) CFLAGS="$CFLAGS -DCPU=\\\"IA64N\\\" -DSO_EXT=\\\"so\\\"" HOST_CPU=IA64N ;; ia64) if test "$host_os" = "hpux" then CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\"" host_cpu=ia64w HOST_CPU=IA64W else CFLAGS="$CFLAGS -DCPU=\\\"ia64\\\"" HOST_CPU=ia64 fi ;; sh*) CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\"" HOST_CPU=$host_cpu;; s390 | s390x) CFLAGS="$CFLAGS -DCPU=\\\"s390\\\"" supported_os="s390" HOST_CPU=s390 ;; arm*) CFLAGS="$CFLAGS -DCPU=\\\"arm\\\"" supported_os="arm" HOST_CPU=arm ;; aarch64) CFLAGS="$CFLAGS -DCPU=\\\"aarch64\\\"" supported_os="aarch64" HOST_CPU=aarch64 ;; *) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Unsupported CPU architecture "$host_cpu"]);; esac if test "x$GCC" = "xyes" then case $host_os-$host_cpu in hpux-ia64n) CFLAGS="-milp32 -pthread $CFLAGS" LDFLAGS="-milp32 -pthread $LDFLAGS" LIBS="$LIBS -lpthread" ;; hpux-ia64w) CFLAGS="-mlp64 -pthread $CFLAGS" LDFLAGS="-mlp64 -pthread $LDFLAGS" LIBS="$LIBS -lpthread" ;; hpux-*) CFLAGS="-pthread $CFLAGS" LDFLAGS="-pthread $LDFLAGS" LIBS="$LIBS -lpthread" ;; *) ;; esac else case $host_os-$host_cpu in hpux-ia64n|hpux-hppa2.0n) CFLAGS="+DD32 -mt $CFLAGS" LDFLAGS="+DD32 -mt $LDFLAGS" ;; hpux-ia64w|hpux-hppa2.0w) CFLAGS="+DD64 -mt $CFLAGS" LDFLAGS="+DD64 -mt $LDFLAGS" ;; hpux-*) CFLAGS="-mt $CFLAGS" LDFLAGS="-mt $LDFLAGS" ;; *) ;; esac fi AC_MSG_RESULT([ok]) AC_SUBST(CFLAGS) AC_SUBST(LDFLAGS) ]) commons-daemon-1.1.0-native-src/unix/support/config.sub 0100775 0001750 0001750 00000106763 13010206346 023501 0 ustar 00mark mark 0000000 0000000 #! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2016 Free Software Foundation, Inc. timestamp='2016-11-04' # 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 3 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, see <http://www.gnu.org/licenses/>. # # 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. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to <config-patches@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. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # 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 or 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@gnu.org>." version="\ GNU config.sub ($timestamp) Copyright 1992-2016 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 ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # 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 ;; * ) 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* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) 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 | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -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/'` ;; -sco5v6*) # 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*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -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. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # 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. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # 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 ;; abacus) basic_machine=abacus-unknown ;; 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 ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; 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 ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; 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 | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; e500v[12]) basic_machine=powerpc-unknown os=$os"spe" ;; e500v[12]-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` os=$os"spe" ;; 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*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 ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; 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 ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; 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 ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-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 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; 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=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; 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 ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-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 ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; 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 ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) 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 ;; *-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. -auroraux) os=-auroraux ;; -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* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ | -onefs* | -tirtos* | -phoenix* | -fuchsia*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -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 ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -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 ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -ios) ;; -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 score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. 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 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-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 ;; -cnk*|-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 ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: commons-daemon-1.1.0-native-src/unix/support/apfunctions.m4 0100664 0001750 0001750 00000005335 13130530741 024304 0 ustar 00mark mark 0000000 0000000 dnl dnl Licensed to the Apache Software Foundation (ASF) under one or more dnl contributor license agreements. See the NOTICE file distributed with dnl this work for additional information regarding copyright ownership. dnl The ASF licenses this file to You under the Apache License, Version 2.0 dnl (the "License"); you may not use this file except in compliance with dnl the License. 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 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]) ]) dnl Iteratively interpolate the contents of the second argument dnl until interpolation offers no new result. Then assign the dnl final result to $1. dnl dnl Example: dnl dnl foo=1 dnl bar='${foo}/2' dnl baz='${bar}/3' dnl AP_EXPAND_VAR(fraz, $baz) dnl $fraz is now "1/2/3" dnl AC_DEFUN([AP_EXPAND_VAR], [ ap_last= ap_cur="$2" while test "x${ap_cur}" != "x${ap_last}"; do ap_last="${ap_cur}" ap_cur=`eval "echo ${ap_cur}"` done $1="${ap_cur}" ]) dnl dnl AP_CONFIG_NICE(filename) dnl dnl Saves a snapshot of the configure command-line for later reuse dnl AC_DEFUN([AP_CONFIG_NICE], [ rm -f $1 cat >$1<<EOF #! /bin/sh # # Created by configure EOF if test -n "$CC"; then echo "CC=\"$CC\"; export CC" >> $1 fi if test -n "$CFLAGS"; then echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1 fi if test -n "$CPPFLAGS"; then echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1 fi if test -n "$LDFLAGS"; then echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1 fi if test -n "$LIBS"; then echo "LIBS=\"$LIBS\"; export LIBS" >> $1 fi if test -n "$STRIPFLAGS"; then echo "STRIPFLAGS=\"$STRIPFLAGS\"; export STRIPFLAGS" >> $1 fi if test -n "$INCLUDES"; then echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1 fi # Retrieve command-line arguments. eval "set x $[0] $ac_configure_args" shift for arg do AP_EXPAND_VAR(arg, $arg) echo "\"[$]arg\" \\" >> $1 done echo '"[$]@"' >> $1 chmod +x $1 ])dnl commons-daemon-1.1.0-native-src/unix/support/apjava.m4 0100664 0001750 0001750 00000005163 13130530741 023214 0 ustar 00mark mark 0000000 0000000 dnl dnl Licensed to the Apache Software Foundation (ASF) under one or more dnl contributor license agreements. See the NOTICE file distributed with dnl this work for additional information regarding copyright ownership. dnl The ASF licenses this file to You under the Apache License, Version 2.0 dnl (the "License"); you may not use this file except in compliance with dnl the License. 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 AC_DEFUN([AP_FIND_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_CHECKING([for JDK location]) # Oh well, nobody set JAVA_HOME, have to guess # Check if we have java in the PATH. java_prog="`which java 2>/dev/null || true`" if test "x$java_prog" != x then java_bin="`dirname $java_prog`" java_top="`dirname $java_bin`" if test -f "$java_top/include/jni.h" then JAVA_HOME="$java_top" AC_MSG_RESULT([${java_top}]) fi fi fi if test x"$JAVA_HOME" = x then AC_MSG_ERROR([Java Home not defined. Rerun with --with-java=[...] parameter]) fi ]) AC_DEFUN([AP_FIND_JAVA_OS],[ tempval="" JAVA_OS="" AC_ARG_WITH(os-type,[ --with-os-type[=SUBDIR] Location of JDK os-type subdirectory.], [ tempval=$withval if test ! -d "$JAVA_HOME/$tempval" then AC_MSG_ERROR(Not a directory: ${JAVA_HOME}/${tempval}) fi JAVA_OS=$tempval ], [ AC_MSG_CHECKING(for JDK os include directory) JAVA_OS=NONE if test -f $JAVA_HOME/$JAVA_INC/jni_md.h then JAVA_OS="" else for f in $JAVA_HOME/$JAVA_INC/*/jni_md.h do if test -f $f; then JAVA_OS=`dirname $f` JAVA_OS=`basename $JAVA_OS` echo " $JAVA_OS" break fi done if test "x$JAVA_OS" = "xNONE"; then AC_MSG_RESULT(Cannot find jni_md.h in ${JAVA_HOME}/${OS}) AC_MSG_ERROR(You should retry --with-os-type=SUBDIR) fi fi ]) ]) commons-daemon-1.1.0-native-src/unix/Makefile.in 0100664 0001750 0001750 00000002126 13130530533 022034 0 ustar 00mark mark 0000000 0000000 # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. # 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 config.nice rm -f native/Makefile rm -f Makefile rm -f Makedefs rm -rf autom4te.cache realclean: distclean rm -f configure commons-daemon-1.1.0-native-src/unix/configure 0100775 0001750 0001750 00000437602 13203026443 021712 0 ustar 00mark mark 0000000 0000000 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 </dev/null exec 6>&1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="configure.in" # Factoring default headers for most tests. ac_includes_default="\ #include <stdio.h> #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #ifdef STDC_HEADERS # include <stdlib.h> # include <stddef.h> #else # ifdef HAVE_STDLIB_H # include <stdlib.h> # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include <memory.h> # endif # include <string.h> #endif #ifdef HAVE_STRINGS_H # include <strings.h> #endif #ifdef HAVE_INTTYPES_H # include <inttypes.h> #endif #ifdef HAVE_STDINT_H # include <stdint.h> #endif #ifdef HAVE_UNISTD_H # include <unistd.h> #endif" ac_subst_vars='LTLIBOBJS LIBOBJS INCLUDES EGREP GREP CPP LDCMD JAVA_HOME STRIP RANLIB OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_java with_os_type ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-java=DIR Specify the location of your JDK installation --with-os-type=SUBDIR Location of JDK os-type subdirectory. Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir> LIBS libraries to pass to the linker, e.g. -l<library> CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` 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 || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in ./support "$srcdir"/./support; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in ./support \"$srcdir\"/./support" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. rm -f config.nice cat >config.nice<<EOF #! /bin/sh # # Created by configure EOF if test -n "$CC"; then echo "CC=\"$CC\"; export CC" >> config.nice fi if test -n "$CFLAGS"; then echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> config.nice fi if test -n "$CPPFLAGS"; then echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> config.nice fi if test -n "$LDFLAGS"; then echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> config.nice fi if test -n "$LIBS"; then echo "LIBS=\"$LIBS\"; export LIBS" >> config.nice fi if test -n "$STRIPFLAGS"; then echo "STRIPFLAGS=\"$STRIPFLAGS\"; export STRIPFLAGS" >> config.nice fi if test -n "$INCLUDES"; then echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> config.nice fi # Retrieve command-line arguments. eval "set x $0 $ac_configure_args" shift for arg do ap_last= ap_cur="$arg" while test "x${ap_cur}" != "x${ap_last}"; do ap_last="${ap_cur}" ap_cur=`eval "echo ${ap_cur}"` done arg="${ap_cur}" echo "\"$arg\" \\" >> config.nice done echo '"$@"' >> config.nice chmod +x config.nice printf "*** %s ***\n" "Current host" 1>&2 # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking cached host system type" >&5 $as_echo_n "checking cached host system type... " >&6; } if { test x"${ac_cv_host_system_type+set}" = x"set" && test x"$ac_cv_host_system_type" != x"$host" ; } then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host_system_type" >&5 $as_echo "$ac_cv_host_system_type" >&6; } as_fn_error $? "remove the \"$cache_file\" file and re-run configure" "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } ac_cv_host_system_type="$host" fi printf "*** %s ***\n" "C-Language compilation tools" 1>&2 ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdio.h> int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdarg.h> #include <stdio.h> struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi printf "*** %s ***\n" "Host support" 1>&2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking C flags dependant on host system type" >&5 $as_echo_n "checking C flags dependant on host system type... " >&6; } case $host_os in darwin*) CFLAGS="$CFLAGS -DOS_DARWIN -DDSO_DLFCN" 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" supported_os="sysv" ;; sysv4) CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN -Kthread" LDFLAGS="-Kthread $LDFLAGS" LIBS="$LIBS -ldl" supported_os="sysv4" ;; 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" supported_os="osf5" ;; hpux*) CFLAGS="$CFLAGS -DOS_HPUX -DDSO_DLFCN" supported_os="hp-ux" host_os="hpux" ;; aix5*) CFLAGS="$CFLAGS -DOS_AIX -DDSO_DLFCN" LDFLAGS="$LDFLAGS -ldl" supported_os="aix5" ;; kfreebsd*-gnu) CFLAGS="$CFLAGS -DOS_BSD -DDSO_DLFCN -pthread" supported_os="kfreebsd-gnu" LIBS="$LIBS -ldl -lpthread" ;; gnu*) CFLAGS="$CFLAGS -DOS_HURD -DDSO_DLFCN -pthread " supported_os="hurd-gnu" LIBS="$LIBS -ldl -lpthread" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } as_fn_error $? "Unsupported operating system \"$host_os\"" "$LINENO" 5 ;; esac case $host_cpu in powerpc64) CFLAGS="$CFLAGS -DCPU=\\\"ppc64\\\"" HOST_CPU=ppc64 ;; powerpc64le) CFLAGS="$CFLAGS -DCPU=\\\"ppc64le\\\"" HOST_CPU=ppc64le ;; powerpc*) CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\"" HOST_CPU=$host_cpu ;; sparc*) CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\"" HOST_CPU=$host_cpu ;; i?86|x86) CFLAGS="$CFLAGS -DCPU=\\\"i386\\\"" HOST_CPU=i386 ;; x86_64 | amd64) 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 | mipsn32 | mips64) CFLAGS="$CFLAGS -DCPU=\\\"mips\\\"" supported_os="mips" HOST_CPU=mips ;; alpha*) CFLAGS="$CFLAGS -DCPU=\\\"alpha\\\"" supported_os="alpha" HOST_CPU=alpha ;; hppa2.0w|hppa64) CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0W\\\" -DSO_EXT=\\\"sl\\\"" host_cpu=hppa2.0w HOST_CPU=PA_RISC2.0W ;; hppa2.0n|hppa32) CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0N\\\" -DSO_EXT=\\\"sl\\\"" HOST_CPU=PA_RISC2.0N ;; hppa2.0) if test "$host_os" = "hpux" then host_cpu=hppa2.0w HOST_CPU=PA_RISC2.0W else HOST_CPU=PA_RISC2.0 fi CFLAGS="$CFLAGS -DCPU=\\\"$HOST_CPU\\\" -DSO_EXT=\\\"sl\\\"" ;; mipsel | mipsn32el | mips64el) CFLAGS="$CFLAGS -DCPU=\\\"mipsel\\\"" supported_os="mipsel" HOST_CPU=mipsel ;; ia64w) CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\"" HOST_CPU=IA64W ;; ia64n) CFLAGS="$CFLAGS -DCPU=\\\"IA64N\\\" -DSO_EXT=\\\"so\\\"" HOST_CPU=IA64N ;; ia64) if test "$host_os" = "hpux" then CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\"" host_cpu=ia64w HOST_CPU=IA64W else CFLAGS="$CFLAGS -DCPU=\\\"ia64\\\"" HOST_CPU=ia64 fi ;; sh*) CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\"" HOST_CPU=$host_cpu;; s390 | s390x) CFLAGS="$CFLAGS -DCPU=\\\"s390\\\"" supported_os="s390" HOST_CPU=s390 ;; arm*) CFLAGS="$CFLAGS -DCPU=\\\"arm\\\"" supported_os="arm" HOST_CPU=arm ;; aarch64) CFLAGS="$CFLAGS -DCPU=\\\"aarch64\\\"" supported_os="aarch64" HOST_CPU=aarch64 ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } as_fn_error $? "Unsupported CPU architecture \"$host_cpu\"" "$LINENO" 5;; esac if test "x$GCC" = "xyes" then case $host_os-$host_cpu in hpux-ia64n) CFLAGS="-milp32 -pthread $CFLAGS" LDFLAGS="-milp32 -pthread $LDFLAGS" LIBS="$LIBS -lpthread" ;; hpux-ia64w) CFLAGS="-mlp64 -pthread $CFLAGS" LDFLAGS="-mlp64 -pthread $LDFLAGS" LIBS="$LIBS -lpthread" ;; hpux-*) CFLAGS="-pthread $CFLAGS" LDFLAGS="-pthread $LDFLAGS" LIBS="$LIBS -lpthread" ;; *) ;; esac else case $host_os-$host_cpu in hpux-ia64n|hpux-hppa2.0n) CFLAGS="+DD32 -mt $CFLAGS" LDFLAGS="+DD32 -mt $LDFLAGS" ;; hpux-ia64w|hpux-hppa2.0w) CFLAGS="+DD64 -mt $CFLAGS" LDFLAGS="+DD64 -mt $LDFLAGS" ;; hpux-*) CFLAGS="-mt $CFLAGS" LDFLAGS="-mt $LDFLAGS" ;; *) ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } if test "$supported_os" = "darwin" then if test -z "$JAVA_HOME" -a -x /usr/libexec/java_home then JAVA_HOME="`/usr/libexec/java_home 2>dev/null`" fi 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 INCLUDES="$INCLUDES -I`/bin/pwd -P`" cd $_prevdir unset _prevdir fi printf "*** %s ***\n" "Java compilation tools" 1>&2 # Check whether --with-java was given. if test "${with_java+set}" = set; then : withval=$with_java; { $as_echo "$as_me:${as_lineno-$LINENO}: checking JAVA_HOME" >&5 $as_echo_n "checking JAVA_HOME... " >&6; } if test -d "$withval" then JAVA_HOME="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVA_HOME" >&5 $as_echo "$JAVA_HOME" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } as_fn_error $? "$withval is not a directory" "$LINENO" 5 fi fi if test "x$JAVA_HOME" = x then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JDK location" >&5 $as_echo_n "checking for JDK location... " >&6; } # Oh well, nobody set JAVA_HOME, have to guess # Check if we have java in the PATH. java_prog="`which java 2>/dev/null || true`" if test "x$java_prog" != x then java_bin="`dirname $java_prog`" java_top="`dirname $java_bin`" if test -f "$java_top/include/jni.h" then JAVA_HOME="$java_top" { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${java_top}" >&5 $as_echo "${java_top}" >&6; } fi fi fi if test x"$JAVA_HOME" = x then as_fn_error $? "Java Home not defined. Rerun with --with-java=... parameter" "$LINENO" 5 fi if test -d $JAVA_HOME/Headers then JAVA_INC=Headers else JAVA_INC=include fi tempval="" JAVA_OS="" # Check whether --with-os-type was given. if test "${with_os_type+set}" = set; then : withval=$with_os_type; tempval=$withval if test ! -d "$JAVA_HOME/$tempval" then as_fn_error $? "Not a directory: ${JAVA_HOME}/${tempval}" "$LINENO" 5 fi JAVA_OS=$tempval else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JDK os include directory" >&5 $as_echo_n "checking for JDK os include directory... " >&6; } JAVA_OS=NONE if test -f $JAVA_HOME/$JAVA_INC/jni_md.h then JAVA_OS="" else for f in $JAVA_HOME/$JAVA_INC/*/jni_md.h do if test -f $f; then JAVA_OS=`dirname $f` JAVA_OS=`basename $JAVA_OS` echo " $JAVA_OS" break fi done if test "x$JAVA_OS" = "xNONE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Cannot find jni_md.h in ${JAVA_HOME}/${OS}" >&5 $as_echo "Cannot find jni_md.h in ${JAVA_HOME}/${OS}" >&6; } as_fn_error $? "You should retry --with-os-type=SUBDIR" "$LINENO" 5 fi fi fi if test -z "${JAVA_OS}" then { $as_echo "$as_me:${as_lineno-$LINENO}: result: jni_md.h found in $JAVA_HOME/$JAVA_INC" >&5 $as_echo "jni_md.h found in $JAVA_HOME/$JAVA_INC" >&6; } INCLUDES="$INCLUDES -I$JAVA_HOME/include -I$JAVA_HOME/$JAVA_INC" else INCLUDES="$INCLUDES -I$JAVA_HOME/include -I$JAVA_HOME/include/$supported_os" fi if test "$GCC" = "yes" then CFLAGS="$CFLAGS -Wall -Wstrict-prototypes" { $as_echo "$as_me:${as_lineno-$LINENO}: result: gcc flags added" >&5 $as_echo "gcc flags added" >&6; } fi if test -z "$LDCMD" then LDCMD="$CC" fi if test "$supported_os" = "linux" then ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since # <limits.h> exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include <limits.h> #else # include <assert.h> #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <ac_nonexistent.h> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since # <limits.h> exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include <limits.h> #else # include <assert.h> #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <ac_nonexistent.h> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <float.h> int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <string.h> _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdlib.h> _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <ctype.h> #include <stdlib.h> #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "sys/capability.h" "ac_cv_header_sys_capability_h" "$ac_includes_default" if test "x$ac_cv_header_sys_capability_h" = xyes; then : CFLAGS="$CFLAGS -DHAVE_LIBCAP" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find headers for libcap" >&5 $as_echo "$as_me: WARNING: cannot find headers for libcap" >&2;} fi fi if test -z "$STRIPFLAGS" then STRIP="@: " else STRIP="$STRIP $STRIPFLAGS" fi printf "*** %s ***\n" "Writing output files" 1>&2 ac_config_files="$ac_config_files Makefile Makedefs native/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "Makedefs") CONFIG_FILES="$CONFIG_FILES Makedefs" ;; "native/Makefile") CONFIG_FILES="$CONFIG_FILES native/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' <conf$$subs.awk | sed ' /^[^""]/{ N s/\n// } ' >>$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi printf "*** %s ***\n" "All done" 1>&2 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Now you can issue \"make\"" >&5 $as_echo "Now you can issue \"make\"" >&6; } commons-daemon-1.1.0-native-src/unix/man/fetch.sh 0100775 0001750 0001750 00000002440 11511404362 022172 0 ustar 00mark mark 0000000 0000000 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. 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 commons-daemon-1.1.0-native-src/unix/support/mkdist.sh 0100775 0001750 0001750 00000006154 11457754054 023362 0 ustar 00mark mark 0000000 0000000 #!/bin/sh # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. # # Create Commons Daemon native package distribution on UNIX systems. # You should execute this script from the src/native/unix directory # # support/mkdist.sh <arch> [os] # # This will create something like commons-daemon-1.2.3-bin-os-arch.tar.gz # The version numbers are parsed from the native/version.h file. # If the os argument is not provided current os name will be used. # # gpgopts="-ba" arch="" for o do case "$o" in *=*) a=`echo "$o" | sed 's/^[-_a-zA-Z0-9]*=//'` ;; *) a='' ;; esac case "$o" in --passphrase=* ) gpgopts="$gpgopts --passphrase $a" shift ;; --arch=* ) arch="$a" shift ;; --os=* ) osname="$a" shift ;; * ) break ;; esac done if [ ".$arch" = . ];then arch=`uname -m 2>/dev/null | tr '[A-Z]' '[a-z]'` || arch="unknown" echo "No architecture provided. Using $arch" fi if [ ".$osname" = . ];then osname=`uname -s 2>/dev/null | tr '[A-Z]' '[a-z]'` || osname="unknown" echo "No OS name provided. Using $osname" fi topdir=. major_sed='/#define.*JSVC_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' minor_sed='/#define.*JSVC_MINOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' patch_sed='/#define.*JSVC_PATCH_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' vmajor="`sed -n $major_sed $topdir/native/version.h`" vminor="`sed -n $minor_sed $topdir/native/version.h`" vpatch="`sed -n $patch_sed $topdir/native/version.h`" verdst="commons-daemon-$vmajor.$vminor.$vpatch-bin-$osname-$arch" extfiles="LICENSE.txt NOTICE.txt RELEASE-NOTES.txt" for i in $extfiles do cp ../../../$i . done # Try to locate a MD5 binary md5_bin="`which md5sum 2>/dev/null || type md5sum 2>&1`" if [ -x "$md5_bin" ]; then MD5SUM="$md5_bin --binary " else MD5SUM="echo 00000000000000000000000000000000 " fi # Try to locate a SHA1 binary sha1_bin="`which sha1sum 2>/dev/null || type sha1sum 2>&1`" if [ -x "$sha1_bin" ]; then SHA1SUM="$sha1_bin --binary " else SHA1SUM="echo 0000000000000000000000000000000000000000 " fi dstfile=$verdst.tar.gz echo "Creating $dstfile ..." tar cfz $dstfile jsvc $extfiles if [ ".$?" = .0 ]; then echo "Signing $dstfile" gpg $gpgopts $dstfile $MD5SUM $dstfile > $dstfile.md5 $SHA1SUM $dstfile > $dstfile.sha1 else rm $verdst.tar.gz >/dev/null 2>&1 fi rm $extfiles commons-daemon-1.1.0-native-src/unix/support/install.sh 0100775 0001750 0001750 00000006530 10533242563 023522 0 ustar 00mark mark 0000000 0000000 #!/bin/sh # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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@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 commons-daemon-1.1.0-native-src/unix/support/buildconf.sh 0100775 0001750 0001750 00000002154 13130530533 024010 0 ustar 00mark mark 0000000 0000000 #!/bin/sh # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. # 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 commons-daemon-1.1.0-native-src/windows/ 0040775 0001750 0001750 00000000000 13203026365 020504 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/apps/ 0040775 0001750 0001750 00000000000 13203026365 021447 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/apps/prunmgr/ 0040775 0001750 0001750 00000000000 13203026365 023141 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/apps/prunsrv/ 0040775 0001750 0001750 00000000000 13203026365 023166 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/include/ 0040775 0001750 0001750 00000000000 13203026365 022127 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/resources/ 0040775 0001750 0001750 00000000000 13203026365 022516 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/xdocs/ 0040775 0001750 0001750 00000000000 13203026365 021624 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/src/ 0040775 0001750 0001750 00000000000 13203026365 021273 5 ustar 00mark mark 0000000 0000000 commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.c 0100664 0001750 0001750 00000222702 13200414307 024773 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ /* ==================================================================== * prunmgr -- Service Manager Application. * Contributed by Mladen Turk <mturk@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" " #ifdef WIN64 #define KREG_WOW6432 KEY_WOW64_32KEY #else #define KREG_WOW6432 0 #endif /* 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 prunmgr 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 }; static LPCWSTR _altcmds[] = { L"manage", /* 1 Manage Service (default)*/ L"monitor", /* 2 Monitor Service */ L"start", /* 3 Monitor Service and start if not runing */ L"quit", /* 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 control 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[SIZ_RESLEN]; WCHAR szD[SIZ_DESLEN]; 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, SIZ_RESMAX); GetDlgItemTextW(hDlg, IDC_PPSGDESC, szD, SIZ_DESMAX); 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[SIZ_RESLEN]; WCHAR szP[SIZ_RESLEN]; WCHAR szC[SIZ_RESLEN]; 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, SIZ_RESMAX); GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, SIZ_RESMAX); GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, SIZ_RESMAX); if (lstrlenW(szU) && lstrcmpiW(szU, STAT_SYSTEM)) { if (szP[0] != L' ' && szC[0] != L' ' && !lstrcmpW(szP, szC)) { apxServiceSetNames(hService, NULL, NULL, NULL, szU, szP); lstrlcpyW(_currentEntry->szObjectName, SIZ_RESLEN, szU); } else { MessageBoxW(hDlg, apxLoadResourceW(IDS_VALIDPASS, 0), apxLoadResourceW(IDS_APPLICATION, 1), MB_OK | MB_ICONSTOP); return FALSE; } } else { apxServiceSetNames(hService, NULL, NULL, NULL, STAT_SYSTEM, L""); lstrlcpyW(_currentEntry->szObjectName, SIZ_RESLEN, STAT_SYSTEM); 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_PPLGPIDFILE, szB, SIZ_DESMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_log, L"PidFile", 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_HUGLEN]; 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_HUGMAX); } else lstrcpyW(szB, L"auto"); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"Jvm", szB); GetDlgItemTextW(hDlg, IDC_PPJCLASSPATH, szB, SIZ_HUGMAX); 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_HUGMAX)) szB[0] = L'\0'; l = GetWindowTextLength(GetDlgItem(hDlg, IDC_PPJOPTIONS9)); p = apxPoolAlloc(hPool, (l + 2) * sizeof(WCHAR)); GetDlgItemTextW(hDlg, IDC_PPJOPTIONS9, p, l + 1); s = apxCRLFToMszW(hPool, p, &l); apxFree(p); apxRegistrySetMzStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"Options9", s, l); if (!GetDlgItemTextW(hDlg, IDC_PPJMS, szB, SIZ_HUGMAX)) 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_HUGLEN]; 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_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Class", szB); GetDlgItemTextW(hDlg, IDC_PPRIMAGE, szB, SIZ_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Image", szB); GetDlgItemTextW(hDlg, IDC_PPRWPATH, szB, SIZ_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"WorkingPath", szB); GetDlgItemTextW(hDlg, IDC_PPRMETHOD, szB, SIZ_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Method", szB); GetDlgItemTextW(hDlg, IDC_PPRMODE, szB, SIZ_HUGMAX); 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_HUGLEN]; 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_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Class", szB); GetDlgItemTextW(hDlg, IDC_PPSIMAGE, szB, SIZ_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Image", szB); GetDlgItemTextW(hDlg, IDC_PPSWPATH, szB, SIZ_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"WorkingPath", szB); GetDlgItemTextW(hDlg, IDC_PPSMETHOD, szB, SIZ_HUGMAX); apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Method", szB); GetDlgItemTextW(hDlg, IDC_PPSTIMEOUT, szB, SIZ_HUGMAX); apxRegistrySetNumW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Timeout", apxAtoulW(szB)); GetDlgItemTextW(hDlg, IDC_PPSMODE, szB, SIZ_HUGMAX); 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; static HWND _generalPropertyHwnd = NULL; LRESULT CALLBACK __generalProperty(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam) { LPPSHNOTIFY lpShn; WCHAR szBuf[SIZ_DESLEN]; switch (uMessage) { case WM_INITDIALOG: { _generalPropertyHwnd = hDlg; 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, SIZ_RESMAX, 0); SendMessage(GetDlgItem(hDlg, IDC_PPSGDESC), EM_LIMITTEXT, SIZ_DESMAX, 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, SIZ_RESMAX); 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, SIZ_DESMAX); 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, apxLoadResourceW(IDS_HSSTART, 0), _currentEntry->lpConfig->lpDisplayName, __startServiceCallback, NULL); __generalPropertyRefresh(hDlg); break; case IDC_PPSGSTOP: apxProgressBox(hDlg, apxLoadResourceW(IDS_HSSTOP, 0), _currentEntry->lpConfig->lpDisplayName, __stopServiceCallback, NULL); __generalPropertyRefresh(hDlg); break; case IDC_PPSGPAUSE: apxProgressBox(hDlg, apxLoadResourceW(IDS_HSPAUSE, 0), _currentEntry->lpConfig->lpDisplayName, __pauseServiceCallback, NULL); __generalPropertyRefresh(hDlg); break; case IDC_PPSGRESTART: apxProgressBox(hDlg, apxLoadResourceW(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[SIZ_DESLEN]; 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, SIZ_RESMAX); 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[SIZ_RESLEN]; WCHAR szC[SIZ_RESLEN]; GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, SIZ_RESMAX); GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, SIZ_RESMAX); /* 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), 1); 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"Prefix")) != NULL) { SetDlgItemTextW(hDlg, IDC_PPLGPREFIX, b); apxFree(b); } else SetDlgItemTextW(hDlg, IDC_PPLGPREFIX, L"commons-daemon"); if ((b = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE, _s_log, L"PidFile")) != NULL) { SetDlgItemTextW(hDlg, IDC_PPLGPIDFILE, 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_PPLGPIDFILE: 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); } if ((lpBuf = apxRegistryGetMzStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"Options9", NULL, NULL)) != NULL) { LPWSTR p = apxMszToCRLFW(hPool, lpBuf); SetDlgItemTextW(hDlg, IDC_PPJOPTIONS9, 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_PPJOPTIONS9: 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"exe"); 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"exe"); 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[SIZ_DESLEN] = {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) lstrlcpyW(szT, SIZ_DESMAX, _currentEntry->lpConfig->lpDisplayName); else return; lstrlcatW(szT, SIZ_DESMAX, 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; _generalPropertyHwnd = NULL; if (!bEnableTry) PostQuitMessage(0); bpropCentered = FALSE; } static void signalService(LPCWSTR szServiceName) { HANDLE event; WCHAR en[SIZ_DESLEN]; int i; lstrlcpyW(en, SIZ_DESLEN, L"Global\\"); lstrlcatW(en, SIZ_DESLEN, szServiceName); lstrlcatW(en, SIZ_DESLEN, L"SIGNAL"); for (i = 7; i < lstrlenW(en); i++) { if (en[i] == L' ') en[i] = L'_'; else en[i] = towupper(en[i]); } 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 { apxManageTryIconW(hWnd, NIM_ADD, NULL, apxLoadResourceW(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, apxLoadResourceW(IDS_HSSTART, 0), _currentEntry->lpConfig->lpDisplayName, __startServiceCallback, NULL); break; case IDM_TM_STOP: if (!_propertyOpened) apxProgressBox(hWnd, apxLoadResourceW(IDS_HSSTOP, 0), _currentEntry->lpConfig->lpDisplayName, __stopServiceCallback, NULL); break; case IDM_TM_PAUSE: if (!_propertyOpened) apxProgressBox(hWnd, apxLoadResourceW(IDS_HSPAUSE, 0), _currentEntry->lpConfig->lpDisplayName, __pauseServiceCallback, NULL); break; case IDM_TM_RESTART: if (!_propertyOpened) apxProgressBox(hWnd, apxLoadResourceW(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); /* Setting this to false ensures that the process closes down * cleanly when the configuration window is open and the process * is closed via MQ, */ bEnableTry = FALSE; PostQuitMessage(0); break; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); break; } return FALSE; } static BOOL loadConfiguration() { return TRUE; } static BOOL saveConfiguration() { return TRUE; } static BOOL isManagerRunning = FALSE; static DWORD WINAPI refreshThread(LPVOID lpParam) { while (isManagerRunning) { /* Refresh property window */ DWORD os = 0; if (_currentEntry) os = _currentEntry->stServiceStatus.dwCurrentState; _currentEntry = apxServiceEntry(hService, TRUE); if (_currentEntry && _currentEntry->stServiceStatus.dwCurrentState != os) { if (_gui_store->hMainWnd) PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0); if (_generalPropertyHwnd) __generalPropertyRefresh(_generalPropertyHwnd); } Sleep(1000); } return 0; } /* Main program entry * Since we are independent 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, _altcmds)) == 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, SERVICE_ALL_ACCESS)) { LPWSTR w = lpCmdline->szApplication + lstrlenW(lpCmdline->szApplication) - 1; if (*w == L'w') *w = L'\0'; if (!apxServiceOpen(hService, lpCmdline->szApplication, SERVICE_ALL_ACCESS)) { 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; } _gui_store = apxGuiInitialize(MainWndProc, lpCmdline->szApplication); 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) SendNotifyMessage(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)) { HANDLE hOther = FindWindow(_gui_store->szWndClass, NULL); if (hOther) { SetForegroundWindow(hOther); SendNotifyMessage(hOther, WM_COMMAND, MAKEWPARAM(IDM_TM_CONFIG, 0), 0); } else { /* Skip sytem error message */ SetLastError(ERROR_SUCCESS); if (!quiet) apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ALREAY_RUNING, 0), lpCmdline->szApplication); } goto cleanup; } } hRegistry = apxCreateRegistryW(hPool, KEY_ALL_ACCESS, NULL, apxLoadResourceW(IDS_APPLICATION, 0), APXREG_USER); loadConfiguration(); hRegserv = apxCreateRegistryW(hPool, KEY_READ | KEY_WRITE | KREG_WOW6432, 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; } isManagerRunning = TRUE; CreateThread(NULL, 0, refreshThread, NULL, 0, NULL); /* Create main invisible window */ _gui_store->hMainWnd = CreateWindow(_gui_store->szWndClass, apxLoadResourceW(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); } } isManagerRunning = FALSE; 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; } commons-daemon-1.1.0-native-src/windows/apps/prunmgr/Makefile 0100664 0001750 0001750 00000005261 13177030456 024610 0 ustar 00mark mark 0000000 0000000 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. TARGET = GUI PROJECT = prunmgr !include <..\..\include\Makefile.inc> !IF !DEFINED(PREFIX) || "$(PREFIX)" == "" PREFIX = .\..\..\..\..\..\target !ENDIF !IF !DEFINED(SRCDIR) || "$(SRCDIR)" == "" SRCDIR = .\..\.. !ENDIF !IF "$(CPU)" == "X64" PREFIX = $(PREFIX)\amd64 !ENDIF LFLAGS = $(LFLAGS) /version:1.0 /DYNAMICBASE /NXCOMPAT LIBS = $(LIBS) user32.lib gdi32.lib winspool.lib comdlg32.lib comctl32.lib shlwapi.lib netapi32.lib INCLUDES = -I$(SRCDIR)\include -I$(SRCDIR)\src $(JAVA_INCLUDES) PDBFLAGS = -Fo$(WORKDIR)\ -Fd$(WORKDIR)\$(PROJECT)-src OBJECTS = \ $(WORKDIR)\cmdline.obj \ $(WORKDIR)\console.obj \ $(WORKDIR)\gui.obj \ $(WORKDIR)\handles.obj \ $(WORKDIR)\javajni.obj \ $(WORKDIR)\log.obj \ $(WORKDIR)\mclib.obj \ $(WORKDIR)\registry.obj \ $(WORKDIR)\rprocess.obj \ $(WORKDIR)\service.obj \ $(WORKDIR)\utils.obj \ $(WORKDIR)\prunmgr.obj BUILDEXE = $(WORKDIR)\$(PROJECT).exe BUILDLOC = $(PREFIX) !IF "$(CPU)" == "X64" BUILDLOC = $(PREFIX)\amd64 !ENDIF BUILDPDB = $(WORKDIR)\$(PROJECT).pdb BUILDRES = $(WORKDIR)\$(PROJECT).res BUILDMAN = $(BUILDEXE).manifest all : $(WORKDIR) $(BUILDEXE) $(BUILDLOC) : @if not exist "$(BUILDLOC)\$(NULL)" mkdir "$(BUILDLOC)" $(WORKDIR) : @$(MAKEWORKDIR) {$(SRCDIR)\src}.c{$(WORKDIR)}.obj: $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $< {$(SRCDIR)\apps\prunmgr}.c{$(WORKDIR)}.obj: $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $< $(BUILDRES): $(SRCDIR)/apps/prunmgr/prunmgr.rc $(RC) $(RCFLAGS) /i "$(SRCDIR)\include" /fo $(BUILDRES) $(SRCDIR)/apps/prunmgr/prunmgr.rc $(BUILDEXE): $(WORKDIR) $(OBJECTS) $(BUILDRES) $(LINK) $(LFLAGS) $(OBJECTS) $(BUILDRES) $(LIBS) $(LDIRS) /pdb:$(BUILDPDB) /out:$(BUILDEXE) IF EXIST $(BUILDMAN) \ mt -nologo -manifest $(BUILDMAN) -outputresource:$(BUILDEXE);1 clean: @$(CLEANTARGET) install: $(BUILDLOC) $(WORKDIR) $(BUILDEXE) @xcopy "$(WORKDIR)\*.exe" "$(BUILDLOC)" /Y /Q commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.manifest 0100664 0001750 0001750 00000003131 13017110374 026353 0 ustar 00mark mark 0000000 0000000 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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. --> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="3.1.0.0" processorArchitecture="*" name="Apache.Procrun.Prunmgr" type="win32" /> <description>Apache Procrun Service Manager</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <!-- Windows UAC support --> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> </assembly> commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.h 0100664 0001750 0001750 00000013075 13200414307 025001 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ /* ==================================================================== * Contributed by Mladen Turk <mturk@apache.org> * 05 Aug 2003 * ==================================================================== */ #ifndef _PRUNMGR_H #define _PRUNMGR_H #undef PRG_VERSION #define PRG_VERSION "1.1.0.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_PPLGPIDFILE 2645 #define IDC_PPLGSTDOUT 2646 #define IDC_PPLGBSTDOUT 2647 #define IDC_PPLGSTDERR 2648 #define IDC_PPLGBSTDERR 2649 #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_PPJOPTIONS9 2666 #define IDC_PPJMS 2667 #define IDC_PPJMX 2668 #define IDC_PPJSS 2669 #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 */ commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.manifest 0100664 0001750 0001750 00000003137 12041170067 026434 0 ustar 00mark mark 0000000 0000000 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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. --> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="3.1.0.0" processorArchitecture="*" name="Apache.Procrun.Prunsrv" type="win32" /> <description>Apache Commons Daemon Service Runner</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <!-- Windows UAC support --> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> </assembly> commons-daemon-1.1.0-native-src/windows/apps/prunsrv/Makefile 0100664 0001750 0001750 00000005273 13177030456 024640 0 ustar 00mark mark 0000000 0000000 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. TARGET = EXE PROJECT = prunsrv !include <..\..\include\Makefile.inc> !IF !DEFINED(PREFIX) || "$(PREFIX)" == "" PREFIX = .\..\..\..\..\..\target !ENDIF !IF !DEFINED(SRCDIR) || "$(SRCDIR)" == "" SRCDIR = .\..\.. !ENDIF !IF "$(CPU)" == "X86" LFLAGS = $(LFLAGS) /stack:0x64000 !ENDIF LFLAGS = $(LFLAGS) /version:1.0 /DYNAMICBASE /NXCOMPAT LIBS = $(LIBS) user32.lib gdi32.lib winspool.lib comdlg32.lib comctl32.lib shlwapi.lib netapi32.lib INCLUDES = -I$(SRCDIR)\include -I$(SRCDIR)\src $(JAVA_INCLUDES) PDBFLAGS = -Fo$(WORKDIR)\ -Fd$(WORKDIR)\$(PROJECT)-src OBJECTS = \ $(WORKDIR)\cmdline.obj \ $(WORKDIR)\console.obj \ $(WORKDIR)\gui.obj \ $(WORKDIR)\handles.obj \ $(WORKDIR)\javajni.obj \ $(WORKDIR)\log.obj \ $(WORKDIR)\mclib.obj \ $(WORKDIR)\registry.obj \ $(WORKDIR)\rprocess.obj \ $(WORKDIR)\service.obj \ $(WORKDIR)\utils.obj \ $(WORKDIR)\prunsrv.obj BUILDEXE = $(WORKDIR)\$(PROJECT).exe BUILDLOC = $(PREFIX) !IF "$(CPU)" == "X64" BUILDLOC = $(PREFIX)\amd64 !ENDIF BUILDPDB = $(WORKDIR)\$(PROJECT).pdb BUILDRES = $(WORKDIR)\$(PROJECT).res BUILDMAN = $(BUILDEXE).manifest all : $(WORKDIR) $(BUILDEXE) $(BUILDLOC) : @if not exist "$(BUILDLOC)\$(NULL)" mkdir "$(BUILDLOC)" $(WORKDIR) : @$(MAKEWORKDIR) {$(SRCDIR)\src}.c{$(WORKDIR)}.obj: $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $< {$(SRCDIR)\apps\prunsrv}.c{$(WORKDIR)}.obj: $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $< $(BUILDRES): $(SRCDIR)/apps/prunsrv/prunsrv.rc $(RC) $(RCFLAGS) /i "$(SRCDIR)\include" /fo $(BUILDRES) $(SRCDIR)/apps/prunsrv/prunsrv.rc $(BUILDEXE): $(WORKDIR) $(OBJECTS) $(BUILDRES) $(LINK) $(LFLAGS) $(OBJECTS) $(BUILDRES) $(LIBS) $(LDIRS) /pdb:$(BUILDPDB) /out:$(BUILDEXE) IF EXIST $(BUILDMAN) \ mt -nologo -manifest $(BUILDMAN) -outputresource:$(BUILDEXE);1 clean: @$(CLEANTARGET) install: $(BUILDLOC) $(WORKDIR) $(BUILDEXE) @xcopy "$(WORKDIR)\*.exe" "$(BUILDLOC)" /Y /Q commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.c 0100664 0001750 0001750 00000212767 13200403206 025053 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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@apache.org> * 05 Aug 2003 * ==================================================================== */ /* Force the JNI vprintf functions */ #define _DEBUG_JNI 1 #include "apxwin.h" #include "private.h" #include "prunsrv.h" #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <fcntl.h> #include <io.h> /* _open_osfhandle */ #ifndef MIN #define MIN(a,b) (((a)<(b)) ? (a) : (b)) #endif #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 #define ONE_MINUTE (60 * 1000) #ifdef _WIN64 #define KREG_WOW6432 KEY_WOW64_32KEY #define PRG_BITS 64 #else #define KREG_WOW6432 0 #define PRG_BITS 32 #endif typedef struct APX_STDWRAP { LPCWSTR szLogPath; LPCWSTR szStdOutFilename; LPCWSTR szStdErrFilename; FILE *fpStdOutFile; FILE *fpStdErrFile; } 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_JDK = L"jdk"; static LPCWSTR PRSRV_JRE = L"jre"; static LPCWSTR PRSRV_MANUAL = L"manual"; static LPCWSTR PRSRV_JBIN = L"\\bin\\java.exe"; static LPCWSTR PRSRV_PBIN = L"\\bin"; static LPCWSTR PRSRV_SIGNAL = L"SIGNAL"; static LPCWSTR PRSV_JVMOPTS9 = L"JDK_JAVA_OPTIONS="; static LPCWSTR STYPE_INTERACTIVE = L"interactive"; 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"ES", /* 3 Execute start */ L"SS", /* 4 Stop Service */ L"US", /* 5 Update Service parameters */ L"IS", /* 6 Install Service */ L"DS", /* 7 Delete Service */ L"?", /* 8 Help */ L"VS", /* 9 Version */ NULL }; static LPCWSTR _altcmds[] = { L"run", /* 1 Run Service as console application (default)*/ L"service", /* 2 Run Service */ L"start", /* 3 Start Service */ L"stop", /* 4 Stop Service */ L"update", /* 5 Update Service parameters */ L"install", /* 6 Install Service */ L"delete", /* 7 Delete Service */ L"help", /* 8 Help */ L"version", /* 9 Version */ 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"ServiceUser", L"ServiceUser", NULL, APXCMDOPT_STR | APXCMDOPT_SRV, NULL, 0}, /* 4 */ { L"ServicePassword", L"ServicePassword", NULL, APXCMDOPT_STR | APXCMDOPT_SRV, NULL, 0}, /* 5 */ { L"Startup", L"Startup", NULL, APXCMDOPT_STR | APXCMDOPT_SRV, NULL, 0}, /* 6 */ { L"Type", L"Type", NULL, APXCMDOPT_STR | APXCMDOPT_SRV, NULL, 0}, /* 7 */ { L"DependsOn", L"DependsOn", NULL, APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0}, /* 8 */ { L"Environment", L"Environment", NULL, APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0}, /* 9 */ { L"User", L"User", NULL, APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 10 */ { L"Password", L"Password", NULL, APXCMDOPT_BIN | APXCMDOPT_REG, NULL, 0}, /* 11 */ { L"LibraryPath", L"LibraryPath", NULL, APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 12 */ { L"JavaHome", L"JavaHome", L"Java", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 13 */ { L"Jvm", L"Jvm", L"Java", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 14 */ { L"JvmOptions", L"Options", L"Java", APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0}, /* 15 */ { L"JvmOptions9", L"Options9", L"Java", APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0}, /* 16 */ { L"Classpath", L"Classpath", L"Java", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 17 */ { L"JvmMs", L"JvmMs", L"Java", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0}, /* 18 */ { L"JvmMx", L"JvmMx", L"Java", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0}, /* 19 */ { L"JvmSs", L"JvmSs", L"Java", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0}, /* 20 */ { L"StopImage", L"Image", L"Stop", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 21 */ { L"StopPath", L"WorkingPath", L"Stop", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 22 */ { L"StopClass", L"Class", L"Stop", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 23 */ { L"StopParams", L"Params", L"Stop", APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0}, /* 24 */ { L"StopMethod", L"Method", L"Stop", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 25 */ { L"StopMode", L"Mode", L"Stop", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 26 */ { L"StopTimeout", L"Timeout", L"Stop", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0}, /* 27 */ { L"StartImage", L"Image", L"Start", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 28 */ { L"StartPath", L"WorkingPath", L"Start", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 29 */ { L"StartClass", L"Class", L"Start", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 30 */ { L"StartParams", L"Params", L"Start", APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0}, /* 31 */ { L"StartMethod", L"Method", L"Start", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 32 */ { L"StartMode", L"Mode", L"Start", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 33 */ { L"LogPath", L"Path", L"Log", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 34 */ { L"LogPrefix", L"Prefix", L"Log", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 35 */ { L"LogLevel", L"Level", L"Log", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 36 */ { L"StdError", L"StdError", L"Log", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 37 */ { L"StdOutput", L"StdOutput", L"Log", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0}, /* 38 */ { L"LogJniMessages", L"LogJniMessages", L"Log", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 1}, /* 39 */ { L"PidFile", L"PidFile", L"Log", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0}, /* 40 */ { L"Rotate", L"Rotate", L"Log", APXCMDOPT_INT | 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_SUSER GET_OPT_T(3) #define ST_SPASSWORD GET_OPT_T(4) #define ST_STARTUP GET_OPT_T(5) #define ST_TYPE GET_OPT_T(6) #define SO_DESCRIPTION GET_OPT_V(0) #define SO_DISPLAYNAME GET_OPT_V(1) #define SO_INSTALL GET_OPT_V(2) #define SO_SUSER GET_OPT_V(3) #define SO_SPASSWORD GET_OPT_V(4) #define SO_STARTUP GET_OPT_V(5) #define SO_TYPE GET_OPT_V(6) #define SO_DEPENDSON GET_OPT_V(7) #define SO_ENVIRONMENT GET_OPT_V(8) #define SO_USER GET_OPT_V(9) #define SO_PASSWORD GET_OPT_V(10) #define SO_LIBPATH GET_OPT_V(11) #define SO_JAVAHOME GET_OPT_V(12) #define SO_JVM GET_OPT_V(13) #define SO_JVMOPTIONS GET_OPT_V(14) #define SO_JVMOPTIONS9 GET_OPT_V(15) #define SO_CLASSPATH GET_OPT_V(16) #define SO_JVMMS GET_OPT_I(17) #define SO_JVMMX GET_OPT_I(18) #define SO_JVMSS GET_OPT_I(19) #define SO_STOPIMAGE GET_OPT_V(20) #define SO_STOPPATH GET_OPT_V(21) #define SO_STOPCLASS GET_OPT_V(22) #define SO_STOPPARAMS GET_OPT_V(23) #define SO_STOPMETHOD GET_OPT_V(24) #define SO_STOPMODE GET_OPT_V(25) #define SO_STOPTIMEOUT GET_OPT_I(26) #define SO_STARTIMAGE GET_OPT_V(27) #define SO_STARTPATH GET_OPT_V(28) #define SO_STARTCLASS GET_OPT_V(29) #define SO_STARTPARAMS GET_OPT_V(30) #define SO_STARTMETHOD GET_OPT_V(31) #define SO_STARTMODE GET_OPT_V(32) #define SO_LOGPATH GET_OPT_V(33) #define SO_LOGPREFIX GET_OPT_V(34) #define SO_LOGLEVEL GET_OPT_V(35) #define SO_STDERROR GET_OPT_V(36) #define SO_STDOUTPUT GET_OPT_V(37) #define SO_JNIVFPRINTF GET_OPT_I(38) #define SO_PIDFILE GET_OPT_V(39) #define SO_LOGROTATE GET_OPT_I(40) 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; /* Java used as worker */ static BOOL _java_startup = FALSE; /* Java used for shutdown */ static BOOL _java_shutdown = FALSE; /* Global variables and objects */ static APXHANDLE gPool; static APXHANDLE gWorker; static APX_STDWRAP gStdwrap; /* stdio/stderr redirection */ static int gExitval; static LPWSTR gStartPath; static LPWSTR _jni_jvmpath = NULL; /* Path to jvm dll */ static LPSTR _jni_jvmoptions = NULL; /* jvm options */ static LPSTR _jni_jvmoptions9 = NULL; /* java 9+ options */ static LPSTR _jni_classpath = NULL; static LPCWSTR _jni_rparam = NULL; /* Startup arguments */ static LPCWSTR _jni_sparam = NULL; /* Shutdown arguments */ static LPSTR _jni_rmethod = NULL; /* Startup method */ static LPSTR _jni_smethod = NULL; /* Shutdown method */ static LPSTR _jni_rclass = NULL; /* Startup class */ static LPSTR _jni_sclass = NULL; /* Shutdown class */ static HANDLE gShutdownEvent = NULL; static HANDLE gSignalEvent = NULL; static HANDLE gSignalThread = NULL; static HANDLE gPidfileHandle = NULL; static LPWSTR gPidfileName = NULL; static BOOL gSignalValid = TRUE; static APXJAVA_THREADARGS gRargs; static APXJAVA_THREADARGS gSargs; DWORD WINAPI eventThread(LPVOID lpParam) { DWORD dwRotateCnt = SO_LOGROTATE; for (;;) { DWORD dw = WaitForSingleObject(gSignalEvent, 1000); if (dw == WAIT_TIMEOUT) { /* Do process maintenance */ if (SO_LOGROTATE != 0 && --dwRotateCnt == 0) { /* Perform log rotation. */ dwRotateCnt = SO_LOGROTATE; } continue; } if (dw == WAIT_OBJECT_0 && gSignalValid) { if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0)) { /* Invoke Thread dump */ if (gWorker && _jni_startup) apxJavaDumpAllStacks(gWorker); } ResetEvent(gSignalEvent); continue; } 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, LPAPXCMDLINE lpCmdline) { BOOL aErr = FALSE; BOOL aOut = FALSE; /* Allocate console if we have none */ if (GetConsoleWindow() == NULL) { HWND hc; AllocConsole(); if ((hc = GetConsoleWindow()) != NULL) ShowWindow(hc, SW_HIDE); } /* redirect to file or console */ if (lpWrapper->szStdOutFilename) { if (lstrcmpiW(lpWrapper->szStdOutFilename, PRSRV_AUTO) == 0) { WCHAR lsn[1024]; aOut = TRUE; lstrlcpyW(lsn, 1020, lpCmdline->szApplication); lstrlcatW(lsn, 1020, L"-stdout"); lstrlocaseW(lsn); lpWrapper->szStdOutFilename = apxLogFile(gPool, lpWrapper->szLogPath, lsn, NULL, TRUE, SO_LOGROTATE); } /* Delete the file if not in append mode * XXX: See if we can use the params instead of that. */ if (!aOut) DeleteFileW(lpWrapper->szStdOutFilename); if ((lpWrapper->fpStdOutFile = _wfopen(lpWrapper->szStdOutFilename, L"a"))) { _dup2(_fileno(lpWrapper->fpStdOutFile), 1); *stdout = *lpWrapper->fpStdOutFile; setvbuf(stdout, NULL, _IONBF, 0); } else lpWrapper->szStdOutFilename = NULL; } if (lpWrapper->szStdErrFilename) { if (lstrcmpiW(lpWrapper->szStdErrFilename, PRSRV_AUTO) == 0) { WCHAR lsn[1024]; aErr = TRUE; lstrlcpyW(lsn, 1020, lpCmdline->szApplication); lstrlcatW(lsn, 1020, L"-stderr"); lstrlocaseW(lsn); lpWrapper->szStdErrFilename = apxLogFile(gPool, lpWrapper->szLogPath, lsn, NULL, TRUE, SO_LOGROTATE); } if (!aErr) DeleteFileW(lpWrapper->szStdErrFilename); if ((lpWrapper->fpStdErrFile = _wfopen(lpWrapper->szStdErrFilename, L"a"))) { _dup2(_fileno(lpWrapper->fpStdErrFile), 2); *stderr = *lpWrapper->fpStdErrFile; setvbuf(stderr, NULL, _IONBF, 0); } else lpWrapper->szStdOutFilename = NULL; } else if (lpWrapper->fpStdOutFile) { _dup2(_fileno(lpWrapper->fpStdOutFile), 2); *stderr = *lpWrapper->fpStdOutFile; setvbuf(stderr, NULL, _IONBF, 0); } return TRUE; } /* Debugging functions */ static void printUsage(LPAPXCMDLINE lpCmdline, BOOL isHelp) { int i = 0; fwprintf(stderr, L"Usage: %s command [ServiceName] [--options]\n", lpCmdline->szExecutable); fwprintf(stderr, L" Commands:\n"); if (isHelp) fwprintf(stderr, L" help This page\n"); fwprintf(stderr, L" install [ServiceName] Install Service\n"); fwprintf(stderr, L" update [ServiceName] Update Service parameters\n"); fwprintf(stderr, L" delete [ServiceName] Delete Service\n"); fwprintf(stderr, L" start [ServiceName] Start Service\n"); fwprintf(stderr, L" stop [ServiceName] Stop Service\n"); fwprintf(stderr, L" run [ServiceName] Run Service as console application\n"); fwprintf(stderr, L" pause [Num Seconds] Sleep for n Seconds (defaults to 60)\n"); fwprintf(stderr, L" version Display version\n"); fwprintf(stderr, L" Options:\n"); while (_options[i].szName) { fwprintf(stderr, L" --%s\n", _options[i].szName); ++i; } } static void printVersion(void) { fwprintf(stderr, L"Commons Daemon Service Runner version %S/Win%d (%S)\n", PRG_VERSION, PRG_BITS, __DATE__); fwprintf(stderr, L"Copyright (c) 2000-2017 The Apache Software Foundation.\n\n" L"For bug reporting instructions, please see:\n" L"<URL:https://issues.apache.org/jira/browse/DAEMON>."); } /* 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++; } } static void setInprocEnvironment9(LPCWSTR szOptions9) { DWORD l, c; LPWSTR e, b; LPCWSTR p; l = __apxGetMultiSzLengthW(szOptions9, &c); if (!c) return; /* environment variable name */ l += lstrlen(PRSV_JVMOPTS9); b = e = apxPoolCalloc(gPool, (l + 1) * sizeof(WCHAR)); p = PRSV_JVMOPTS9; while (*p) { *b++ = *p++; } p = szOptions9; while (c > 0) { if (*p) *b++ = *p; else { *b++ = L' '; c--; } p++; } _wputenv(e); apxFree(e); } /* Load the configuration from Registry * loads only nonspecified items */ static BOOL loadConfiguration(LPAPXCMDLINE lpCmdline) { APXHANDLE hRegistry; int i = 0; if (!lpCmdline->szApplication) { /* Handle empty service names */ apxLogWrite(APXLOG_MARK_WARN "No service name provided"); return FALSE; } SetLastError(ERROR_SUCCESS); hRegistry = apxCreateRegistryW(gPool, KEY_READ | KREG_WOW6432, PRG_REGROOT, lpCmdline->szApplication, APXREG_SOFTWARE | APXREG_SERVICE); if (IS_INVALID_HANDLE(hRegistry)) { if (GetLastError() == ERROR_FILE_NOT_FOUND) apxLogWrite(APXLOG_MARK_WARN "The system cannot find the Registry key for service '%S'", lpCmdline->szApplication); else 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 | KREG_WOW6432, 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; DWORD dwType = SERVICE_WIN32_OWN_PROCESS; WCHAR szImage[SIZ_HUGLEN]; WCHAR szName[SIZ_BUFLEN]; 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 the service type */ if ((ST_TYPE & APXCMDOPT_FOUND) && lstrcmpiW(SO_TYPE, STYPE_INTERACTIVE) == 0) dwType |= SERVICE_INTERACTIVE_PROCESS; /* Check if --Install is provided */ if (!IS_VALID_STRING(SO_INSTALL)) { lstrlcpyW(szImage, SIZ_HUGLEN, lpCmdline->szExePath); lstrlcatW(szImage, SIZ_HUGLEN, L"\\"); lstrlcatW(szImage, SIZ_HUGLEN, lpCmdline->szExecutable); lstrlcatW(szImage, SIZ_HUGLEN, L".exe"); } else lstrlcpyW(szImage, SIZ_HUGLEN, SO_INSTALL); /* Replace not needed quotes */ apxStrQuoteInplaceW(szImage); /* Add run-service command line option */ lstrlcatW(szImage, SIZ_HUGLEN, L" "); lstrlcpyW(szName, SIZ_BUFLEN, L"//RS//"); lstrlcatW(szName, SIZ_BUFLEN, lpCmdline->szApplication); apxStrQuoteInplaceW(szName); lstrlcatW(szImage, SIZ_HUGLEN, szName); 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 */ dwType, dwStart); /* Set the --Description */ if (rv) { LPCWSTR sd = NULL; LPCWSTR su = NULL; LPCWSTR sp = NULL; if (ST_DESCRIPTION & APXCMDOPT_FOUND) { sd = SO_DESCRIPTION; apxLogWrite(APXLOG_MARK_DEBUG "Setting service description %S", SO_DESCRIPTION); } if (ST_SUSER & APXCMDOPT_FOUND) { su = SO_SUSER; apxLogWrite(APXLOG_MARK_DEBUG "Setting service user %S", SO_SUSER); } if (ST_SPASSWORD & APXCMDOPT_FOUND) { sp = SO_SPASSWORD; apxLogWrite(APXLOG_MARK_DEBUG "Setting service password %S", SO_SPASSWORD); } apxServiceSetNames(hService, NULL, NULL, sd, su, sp); } 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; lstrlcpyW(szWndManagerClass, SIZ_RESLEN, lpCmdline->szApplication); lstrlcatW(szWndManagerClass, SIZ_RESLEN, 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, KREG_WOW6432, TRUE); apxLogWrite(APXLOG_MARK_DEBUG "Service '%S' deleted", lpCmdline->szApplication); } else { apxDisplayError(FALSE, 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 '%S' ...", lpCmdline->szApplication); 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(FALSE, NULL, 0, "Unable to open '%S' service", lpCmdline->szApplication); apxCloseHandle(hService); apxLogWrite(APXLOG_MARK_INFO "Stop service finished."); return rv; } static BOOL docmdStartService(LPAPXCMDLINE lpCmdline) { APXHANDLE hService; BOOL rv = FALSE; apxLogWrite(APXLOG_MARK_INFO "Starting service '%S' ...", lpCmdline->szApplication); 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_CONTINUE, 0, NULL, NULL); if (rv) apxLogWrite(APXLOG_MARK_INFO "Started service '%S'", lpCmdline->szApplication); else apxLogWrite(APXLOG_MARK_ERROR "Failed to start service '%S'", lpCmdline->szApplication); } else apxDisplayError(FALSE, NULL, 0, "Unable to open service '%S'", lpCmdline->szApplication); apxCloseHandle(hService); apxLogWrite(APXLOG_MARK_INFO "Start service finished, returning %d", rv); return rv; } static BOOL docmdUpdateService(LPAPXCMDLINE lpCmdline) { APXHANDLE hService; BOOL rv = TRUE; 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)) { /* Close the existing manager handler. * It will be reopened inside install. */ apxCloseHandle(hService); /* In case service doesn't exist try to install it. * Install will fail if there is no minimum parameters required. */ return docmdInstallService(lpCmdline); } else { DWORD dwStart = SERVICE_NO_CHANGE; DWORD dwType = SERVICE_NO_CHANGE; LPCWSTR su = NULL; LPCWSTR sp = NULL; if (ST_SUSER & APXCMDOPT_FOUND) { su = SO_SUSER; apxLogWrite(APXLOG_MARK_DEBUG "Setting service user %S", SO_SUSER); } if (ST_SPASSWORD & APXCMDOPT_FOUND) { sp = SO_SPASSWORD; apxLogWrite(APXLOG_MARK_DEBUG "Setting service password %S", SO_SPASSWORD); } rv = (rv && apxServiceSetNames(hService, NULL, /* Never update the ImagePath */ SO_DISPLAYNAME, SO_DESCRIPTION, su, sp)); /* Update the --Startup mode */ if (ST_STARTUP & APXCMDOPT_FOUND) { if (!lstrcmpiW(SO_STARTUP, PRSRV_AUTO)) dwStart = SERVICE_AUTO_START; else if (!lstrcmpiW(SO_STARTUP, PRSRV_MANUAL)) dwStart = SERVICE_DEMAND_START; } if (ST_TYPE & APXCMDOPT_FOUND) { if (!lstrcmpiW(SO_TYPE, STYPE_INTERACTIVE)) dwType = SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS; } rv = (rv && apxServiceSetOptions(hService, dwType, dwStart, SERVICE_NO_CHANGE)); apxLogWrite(APXLOG_MARK_INFO "Service '%S' updated", lpCmdline->szApplication); rv = (rv && saveConfiguration(lpCmdline)); } apxCloseHandle(hService); if (rv) apxLogWrite(APXLOG_MARK_INFO "Update service finished."); else apxLogWrite(APXLOG_MARK_INFO "Update service '%S' failed.", lpCmdline->szApplication); return rv; } /* Report the service status to the SCM, including service specific exit code */ static BOOL reportServiceStatusE(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint, DWORD dwServiceSpecificExitCode) { static DWORD dwCheckPoint = 1; BOOL fResult = TRUE; apxLogWrite(APXLOG_MARK_DEBUG "reportServiceStatusE: dwCurrentState = %d, dwWin32ExitCode = %d, dwWaitHint = %d, dwServiceSpecificExitCode = %d", dwCurrentState, dwWin32ExitCode, dwWaitHint, dwServiceSpecificExitCode); if (_service_mode && _service_status_handle) { if (dwCurrentState == SERVICE_RUNNING) _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; else _service_status.dwControlsAccepted = 0; _service_status.dwCurrentState = dwCurrentState; _service_status.dwWin32ExitCode = dwWin32ExitCode; _service_status.dwWaitHint = dwWaitHint; _service_status.dwServiceSpecificExitCode = dwServiceSpecificExitCode; 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 */ apxLogWrite(APXLOG_MARK_ERROR "Failed to set service status"); } } return fResult; } /* Report the service status to the SCM */ static BOOL reportServiceStatus(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint) { return reportServiceStatusE(dwCurrentState, dwWin32ExitCode, dwWaitHint, 0); } static BOOL reportServiceStatusStopped(DWORD exitCode) { if (exitCode) { return reportServiceStatusE(SERVICE_STOPPED, ERROR_SERVICE_SPECIFIC_ERROR, 0, exitCode); } else { return reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0); } } 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; } static int onExitStop(void) { if (_service_mode) { apxLogWrite(APXLOG_MARK_DEBUG "Stop exit hook called ..."); reportServiceStatusStopped(0); } return 0; } static int onExitStart(void) { if (_service_mode) { apxLogWrite(APXLOG_MARK_DEBUG "Start exit hook called ..."); apxLogWrite(APXLOG_MARK_DEBUG "VM exit code: %d", apxGetVmExitCode()); /* Reporting the service as stopped even with a non-zero exit code * will not cause recovery actions to be initiated, so don't report at all. * "A service is considered failed when it terminates without reporting a * status of SERVICE_STOPPED to the service controller" * http://msdn.microsoft.com/en-us/library/ms685939(VS.85).aspx */ if (apxGetVmExitCode() == 0) { reportServiceStatusStopped(0); } } return 0; } /* Executed when the service receives stop event */ static DWORD WINAPI serviceStop(LPVOID lpParameter) { APXHANDLE hWorker = NULL; DWORD rv = 0; BOOL wait_to_die = FALSE; DWORD timeout = SO_STOPTIMEOUT * 1000; DWORD dwCtrlType = (DWORD)((BYTE *)lpParameter - (BYTE *)0); 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 (!IS_VALID_STRING(SO_STARTPATH) && IS_VALID_STRING(SO_STOPPATH)) { /* If the Working path is specified change the current directory * but only if the start path wasn't specified already. */ SetCurrentDirectoryW(SO_STOPPATH); } hWorker = apxCreateJava(gPool, _jni_jvmpath); if (IS_INVALID_HANDLE(hWorker)) { apxLogWrite(APXLOG_MARK_ERROR "Failed creating Java %S", _jni_jvmpath); return 1; } gSargs.hJava = hWorker; gSargs.szClassPath = _jni_classpath; gSargs.lpOptions = _jni_jvmoptions; gSargs.lpOptions9 = _jni_jvmoptions9; gSargs.dwMs = SO_JVMMS; gSargs.dwMx = SO_JVMMX; gSargs.dwSs = SO_JVMSS; gSargs.bJniVfprintf = SO_JNIVFPRINTF; gSargs.szClassName = _jni_sclass; gSargs.szMethodName = _jni_smethod; gSargs.lpArguments = _jni_sparam; gSargs.szStdErrFilename = NULL; gSargs.szStdOutFilename = NULL; gSargs.szLibraryPath = SO_LIBPATH; /* Register onexit hook */ _onexit(onExitStop); /* Create shutdown event */ gShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!apxJavaStart(&gSargs)) { apxLogWrite(APXLOG_MARK_ERROR "Failed starting Java"); rv = 3; } else { if (lstrcmpA(_jni_sclass, "java/lang/System") == 0) { reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 20 * 1000); apxLogWrite(APXLOG_MARK_DEBUG "Forcing Java JNI System.exit worker to finish..."); return 0; } 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 (IS_VALID_STRING(SO_STOPMODE)) { /* Only in case we have a stop mode */ DWORD nArgs; LPWSTR *pArgs; if (!IS_VALID_STRING(SO_STOPIMAGE)) { apxLogWrite(APXLOG_MARK_ERROR "Missing service ImageFile"); if (!_service_mode) apxDisplayError(FALSE, NULL, 0, "Service '%S' is missing the ImageFile", _service_name ? _service_name : L"unknown"); return 1; } /* 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 the service process completes before the stop process does the * cleanup code below will free structures required by the stop process * which will, in all probability, trigger a crash. Wait for the stop * process to complete before cleaning up. */ gShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!apxProcessSetExecutableW(hWorker, SO_STOPIMAGE)) { apxLogWrite(APXLOG_MARK_ERROR "Failed setting process executable %S", SO_STOPIMAGE); rv = 2; goto cleanup; } /* Assemble the command line */ if (_java_shutdown) { nArgs = apxJavaCmdInitialize(gPool, SO_CLASSPATH, SO_STOPCLASS, SO_JVMOPTIONS, SO_JVMMS, SO_JVMMX, SO_JVMSS, SO_STOPPARAMS, &pArgs); } else { 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 for 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; } 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 (dwCtrlType == SERVICE_CONTROL_SHUTDOWN) timeout = MIN(timeout, apxGetMaxServiceTimeout(gPool)); reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, timeout); 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 stop thread completed."); SetEvent(gShutdownEvent); 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 */ } if (IS_VALID_STRING(SO_PIDFILE)) { gPidfileName = apxLogFile(gPool, SO_LOGPATH, SO_PIDFILE, NULL, FALSE, 0); if (GetFileAttributesW(gPidfileName) != INVALID_FILE_ATTRIBUTES) { /* Pid file exists */ if (!DeleteFileW(gPidfileName)) { /* Delete failed. Either no access or opened */ apxLogWrite(APXLOG_MARK_ERROR "Pid file '%S' exists", gPidfileName); return 1; } } } GetSystemTimeAsFileTime(&fts); if (_jni_startup) { if (IS_EMPTY_STRING(SO_STARTPATH)) SO_STARTPATH = gStartPath; if (IS_VALID_STRING(SO_STARTPATH)) { /* If the Working path is specified change the current directory */ SetCurrentDirectoryW(SO_STARTPATH); } if (IS_VALID_STRING(SO_LIBPATH)) { /* Add LibraryPath to the PATH */ apxAddToPathW(gPool, SO_LIBPATH); } /* Set the environment using putenv, so JVM can use it */ setInprocEnvironment(); /* Create the JVM global worker */ gWorker = apxCreateJava(gPool, _jni_jvmpath); if (IS_INVALID_HANDLE(gWorker)) { apxLogWrite(APXLOG_MARK_ERROR "Failed creating Java %S", _jni_jvmpath); return 1; } gRargs.hJava = gWorker; gRargs.szClassPath = _jni_classpath; gRargs.lpOptions = _jni_jvmoptions; gRargs.lpOptions9 = _jni_jvmoptions9; gRargs.dwMs = SO_JVMMS; gRargs.dwMx = SO_JVMMX; gRargs.dwSs = SO_JVMSS; gRargs.bJniVfprintf = SO_JNIVFPRINTF; gRargs.szClassName = _jni_rclass; gRargs.szMethodName = _jni_rmethod; gRargs.lpArguments = _jni_rparam; gRargs.szStdErrFilename = gStdwrap.szStdErrFilename; gRargs.szStdOutFilename = gStdwrap.szStdOutFilename; gRargs.szLibraryPath = SO_LIBPATH; /* Register onexit hook */ _onexit(onExitStart); if (!apxJavaStart(&gRargs)) { rv = 4; apxLogWrite(APXLOG_MARK_ERROR "Failed to start Java"); goto cleanup; } apxLogWrite(APXLOG_MARK_DEBUG "Java started %s", _jni_rclass); } else { if (!IS_VALID_STRING(SO_STARTIMAGE)) { apxLogWrite(APXLOG_MARK_ERROR "Missing service ImageFile"); if (!_service_mode) apxDisplayError(FALSE, NULL, 0, "Service '%S' is missing the ImageFile", _service_name ? _service_name : L"unknown"); return 1; } if (IS_VALID_STRING(SO_LIBPATH)) { /* Add LibraryPath to the PATH */ apxAddToPathW(gPool, SO_LIBPATH); } /* Set the environment using putenv, so JVM can use it */ setInprocEnvironment(); setInprocEnvironment9(SO_JVMOPTIONS9); /* Redirect process */ gWorker = apxCreateProcessW(gPool, 0, child_callback, SO_USER, SO_PASSWORD, FALSE); if (IS_INVALID_HANDLE(gWorker)) { apxLogWrite(APXLOG_MARK_ERROR "Failed to create 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 */ if (_java_startup) { nArgs = apxJavaCmdInitialize(gPool, SO_CLASSPATH, SO_STARTCLASS, SO_JVMOPTIONS, SO_JVMMS, SO_JVMMX, SO_JVMSS, SO_STARTPARAMS, &pArgs); } else { 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 to execute process"); goto cleanup; } } if (rv == 0) { FILETIME fte; ULARGE_INTEGER s, e; DWORD nms; /* Create pidfile */ if (gPidfileName) { char pids[32]; gPidfileHandle = CreateFileW(gPidfileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (gPidfileHandle != INVALID_HANDLE_VALUE) { DWORD wr = 0; if (_jni_startup) _snprintf(pids, 32, "%d\r\n", GetCurrentProcessId()); else _snprintf(pids, 32, "%d\r\n", apxProcessGetPid(gWorker)); WriteFile(gPidfileHandle, pids, (DWORD)strlen(pids), &wr, NULL); FlushFileBuffers(gPidfileName); } } 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) { DWORD threadId; HANDLE stopThread; switch (dwCtrlCode) { case SERVICE_CONTROL_SHUTDOWN: apxLogWrite(APXLOG_MARK_INFO "Service SHUTDOWN signalled"); case SERVICE_CONTROL_STOP: reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 3 * 1000); /* Stop the service asynchronously */ stopThread = CreateThread(NULL, 0, serviceStop, (LPVOID)dwCtrlCode, 0, &threadId); CloseHandle(stopThread); return; case SERVICE_CONTROL_INTERROGATE: reportServiceStatus(_service_status.dwCurrentState, _service_status.dwWin32ExitCode, _service_status.dwWaitHint); return; default: break; } } /* 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((LPVOID)SERVICE_CONTROL_STOP); return TRUE; case CTRL_CLOSE_EVENT: apxLogWrite(APXLOG_MARK_INFO "Console CTRL+CLOSE event signaled"); serviceStop((LPVOID)SERVICE_CONTROL_STOP); return TRUE; case CTRL_SHUTDOWN_EVENT: apxLogWrite(APXLOG_MARK_INFO "Console SHUTDOWN event signaled"); serviceStop((LPVOID)SERVICE_CONTROL_SHUTDOWN); return TRUE; case CTRL_LOGOFF_EVENT: apxLogWrite(APXLOG_MARK_INFO "Console LOGOFF event signaled"); if (!_service_mode) { serviceStop((LPVOID)SERVICE_CONTROL_STOP); } return TRUE; break; } return FALSE; } /* Main service execution loop */ void WINAPI serviceMain(DWORD argc, LPTSTR *argv) { DWORD rc = 0; _service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; _service_status.dwCurrentState = SERVICE_START_PENDING; _service_status.dwControlsAccepted = SERVICE_CONTROL_INTERROGATE; _service_status.dwWin32ExitCode = 0; _service_status.dwCheckPoint = 0; _service_status.dwWaitHint = 0; _service_status.dwServiceSpecificExitCode = 0; apxLogWrite(APXLOG_MARK_DEBUG "Inside ServiceMain..."); if (IS_VALID_STRING(_service_name)) { WCHAR en[SIZ_HUGLEN]; int i; PSECURITY_ATTRIBUTES sa = GetNullACL(); lstrlcpyW(en, SIZ_DESLEN, L"Global\\"); lstrlcatW(en, SIZ_DESLEN, _service_name); lstrlcatW(en, SIZ_DESLEN, PRSRV_SIGNAL); for (i = 7; i < lstrlenW(en); i++) { if (en[i] == L' ') en[i] = L'_'; else en[i] = towupper(en[i]); } 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 (IS_VALID_STRING(SO_STARTMODE)) { if (!lstrcmpiW(SO_STARTMODE, PRSRV_JVM)) { _jni_startup = TRUE; if (IS_VALID_STRING(SO_STARTCLASS)) { _jni_rclass = WideToANSI(SO_STARTCLASS); /* Exchange all dots with slashes */ apxStrCharReplaceA(_jni_rclass, '.', '/'); } else { /* Presume its main */ _jni_rclass = WideToANSI(L"Main"); } _jni_rparam = SO_STARTPARAMS; } else if (!lstrcmpiW(SO_STARTMODE, PRSRV_JAVA)) { LPWSTR jx = NULL, szJH = SO_JAVAHOME; if (!szJH) szJH = apxGetJavaSoftHome(gPool, FALSE); else if (!lstrcmpiW(szJH, PRSRV_JDK)) { /* Figure out the JDK JavaHome */ szJH = apxGetJavaSoftHome(gPool, FALSE); } else if (!lstrcmpiW(szJH, PRSRV_JRE)) { /* Figure out the JRE JavaHome */ szJH = apxGetJavaSoftHome(gPool, TRUE); } if (szJH) { jx = apxPoolAlloc(gPool, (lstrlenW(szJH) + 16) * sizeof(WCHAR)); lstrcpyW(jx, szJH); lstrcatW(jx, PRSRV_JBIN); if (!SO_STARTPATH) { /* Use JAVA_HOME/bin as start path */ LPWSTR szJP = apxPoolAlloc(gPool, (lstrlenW(szJH) + 8) * sizeof(WCHAR)); lstrcpyW(szJP, szJH); lstrcatW(szJP, PRSRV_PBIN); SO_STARTPATH = szJP; } } else { apxLogWrite(APXLOG_MARK_ERROR "Unable to find Java Runtime Environment."); goto cleanup; } _java_startup = TRUE; /* StartImage now contains the full path to the java.exe */ SO_STARTIMAGE = jx; } } /* Check the StopMode */ if (IS_VALID_STRING(SO_STOPMODE)) { if (!lstrcmpiW(SO_STOPMODE, PRSRV_JVM)) { _jni_shutdown = TRUE; if (IS_VALID_STRING(SO_STOPCLASS)) { _jni_sclass = WideToANSI(SO_STOPCLASS); apxStrCharReplaceA(_jni_sclass, '.', '/'); } else { /* Defaults to Main */ _jni_sclass = WideToANSI(L"Main"); } _jni_sparam = SO_STOPPARAMS; } else if (!lstrcmpiW(SO_STOPMODE, PRSRV_JAVA)) { LPWSTR jx = NULL, szJH = SO_JAVAHOME; if (!szJH) szJH = apxGetJavaSoftHome(gPool, FALSE); else if (!lstrcmpiW(szJH, PRSRV_JDK)) { /* Figure out the JDK JavaHome */ szJH = apxGetJavaSoftHome(gPool, FALSE); } else if (!lstrcmpiW(szJH, PRSRV_JRE)) { /* Figure out the JRE JavaHome */ szJH = apxGetJavaSoftHome(gPool, TRUE); } if (szJH) { jx = apxPoolAlloc(gPool, (lstrlenW(szJH) + 16) * sizeof(WCHAR)); lstrcpyW(jx, szJH); lstrcatW(jx, PRSRV_JBIN); if (!SO_STOPPATH) { LPWSTR szJP = apxPoolAlloc(gPool, (lstrlenW(szJH) + 8) * sizeof(WCHAR)); lstrcpyW(szJP, szJH); lstrcatW(szJP, PRSRV_PBIN); /* Use JAVA_HOME/bin as stop path */ SO_STOPPATH = szJP; } } else { apxLogWrite(APXLOG_MARK_ERROR "Unable to find Java Runtime Environment."); goto cleanup; } _java_shutdown = TRUE; /* StopImage now contains the full path to the java.exe */ SO_STOPIMAGE = jx; } } /* Find the classpath */ if (_jni_shutdown || _jni_startup) { if (IS_VALID_STRING(SO_JVM)) { if (lstrcmpW(SO_JVM, PRSRV_AUTO)) _jni_jvmpath = SO_JVM; } if (IS_VALID_STRING(SO_CLASSPATH)) _jni_classpath = WideToANSI(SO_CLASSPATH); if (IS_VALID_STRING(SO_STARTMETHOD)) _jni_rmethod = WideToANSI(SO_STARTMETHOD); if (IS_VALID_STRING(SO_STOPMETHOD)) _jni_smethod = WideToANSI(SO_STOPMETHOD); _jni_jvmoptions = MzWideToANSI(SO_JVMOPTIONS); _jni_jvmoptions9 = MzWideToANSI(SO_JVMOPTIONS9); } 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 */ if (!AttachConsole(ATTACH_PARENT_PROCESS) && GetLastError() == ERROR_INVALID_HANDLE) { HWND hc; AllocConsole(); if ((hc = GetConsoleWindow()) != NULL) ShowWindow(hc, SW_HIDE); } } reportServiceStatus(SERVICE_START_PENDING, NO_ERROR, 3000); if ((rc = serviceStart()) == 0) { /* Service is started */ reportServiceStatus(SERVICE_RUNNING, NO_ERROR, 0); apxLogWrite(APXLOG_MARK_DEBUG "Waiting for worker to finish..."); /* Set console handler to capture CTRL events */ SetConsoleCtrlHandler((PHANDLER_ROUTINE)console_handler, TRUE); apxHandleWait(gWorker, INFINITE, FALSE); apxLogWrite(APXLOG_MARK_DEBUG "Worker finished."); } 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"); reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, ONE_MINUTE); WaitForSingleObject(gShutdownEvent, ONE_MINUTE); apxLogWrite(APXLOG_MARK_DEBUG "ShutdownEvent signaled"); CloseHandle(gShutdownEvent); /* This will cause to wait for all threads to exit */ apxLogWrite(APXLOG_MARK_DEBUG "Waiting 1 minute for all threads to exit"); reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, ONE_MINUTE); apxDestroyJvm(ONE_MINUTE); } else { /* We came here without shutdown event * Probably because main() returned without ensuring all threads * have finished */ apxLogWrite(APXLOG_MARK_DEBUG "Waiting for all threads to exit"); apxDestroyJvm(INFINITE); reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0); } apxLogWrite(APXLOG_MARK_DEBUG "JVM destroyed."); reportServiceStatusStopped(apxGetVmExitCode()); return; cleanup: /* Cleanup */ reportServiceStatusStopped(rc); gExitval = rc; return; } /* Run the service in the debug mode */ BOOL docmdDebugService(LPAPXCMDLINE lpCmdline) { _service_mode = FALSE; _service_name = lpCmdline->szApplication; apxLogWrite(APXLOG_MARK_INFO "Debugging '%S' service...", _service_name); serviceMain(0, NULL); apxLogWrite(APXLOG_MARK_INFO "Debug service finished with exit code %d", gExitval); SAFE_CLOSE_HANDLE(gPidfileHandle); if (gPidfileName) { DeleteFileW(gPidfileName); } return gExitval == 0 ? TRUE : FALSE; } BOOL docmdRunService(LPAPXCMDLINE lpCmdline) { BOOL rv; SERVICE_TABLE_ENTRYW dispatch_table[] = { { lpCmdline->szApplication, (LPSERVICE_MAIN_FUNCTIONW)serviceMain }, { NULL, NULL } }; _service_mode = TRUE; _service_name = lpCmdline->szApplication; apxLogWrite(APXLOG_MARK_INFO "Running '%S' Service...", _service_name); if (StartServiceCtrlDispatcherW(dispatch_table)) { apxLogWrite(APXLOG_MARK_INFO "Run service finished."); rv = TRUE; } else { apxLogWrite(APXLOG_MARK_ERROR "StartServiceCtrlDispatcher for '%S' failed", lpCmdline->szApplication); rv = FALSE; } SAFE_CLOSE_HANDLE(gPidfileHandle); if (gPidfileName) { DeleteFileW(gPidfileName); } return rv; } static const char *gSzProc[] = { "", "parse command line arguments", "load configuration", "run service as console application", "run service", "start service", "stop service", "update service parameters", "install service", "delete service", NULL }; void __cdecl main(int argc, char **argv) { UINT rv = 0; LPAPXCMDLINE lpCmdline; if (argc > 1) { DWORD ss = 0; if (strncmp(argv[1], "//PP", 4) == 0) { /* Handy sleep routine defaulting to 1 minute */ if (argv[1][4] && argv[1][5] && argv[1][6]) { int us = atoi(argv[1] + 6); if (us > 0) ss = (DWORD)us; } Sleep(ss * 1000); ExitProcess(0); return; } else if (strcmp(argv[1], "pause") == 0) { /* Handy sleep routine defaulting to 1 minute */ if (argc > 2) { int us = atoi(argv[2]); if (us > 0) ss = (DWORD)us; } } if (ss) { Sleep(ss * 1000); ExitProcess(0); return; } } apxHandleManagerInitialize(); /* Create the main Pool */ gPool = apxPoolCreate(NULL, 0); /* Parse the command line */ if ((lpCmdline = apxCmdlineParse(gPool, _options, _commands, _altcmds)) == NULL) { apxLogWrite(APXLOG_MARK_ERROR "Invalid command line arguments"); rv = 1; goto cleanup; } apxCmdlineLoadEnvVars(lpCmdline); if (lpCmdline->dwCmdIndex < 6) { if (!loadConfiguration(lpCmdline) && lpCmdline->dwCmdIndex < 5) { apxLogWrite(APXLOG_MARK_ERROR "Load configuration failed"); rv = 2; goto cleanup; } } apxLogOpen(gPool, SO_LOGPATH, SO_LOGPREFIX, SO_LOGROTATE); apxLogLevelSetW(NULL, SO_LOGLEVEL); apxLogWrite(APXLOG_MARK_DEBUG "Commons Daemon procrun log initialized"); if (SO_LOGROTATE) apxLogWrite(APXLOG_MARK_DEBUG "Log will rotate each %d seconds.", SO_LOGROTATE); apxLogWrite(APXLOG_MARK_INFO "Commons Daemon procrun (%s %d-bit) started", PRG_VERSION, PRG_BITS); AplZeroMemory(&gStdwrap, sizeof(APX_STDWRAP)); gStartPath = lpCmdline->szExePath; gStdwrap.szLogPath = SO_LOGPATH; /* In debug mode allways use console */ if (lpCmdline->dwCmdIndex != 1) { gStdwrap.szStdOutFilename = SO_STDOUTPUT; gStdwrap.szStdErrFilename = SO_STDERROR; } redirectStdStreams(&gStdwrap, lpCmdline); if (lpCmdline->dwCmdIndex == 2) { SYSTEMTIME t; GetLocalTime(&t); fprintf(stdout, "\n%d-%02d-%02d %02d:%02d:%02d " "Commons Daemon procrun stdout initialized\n", t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); fprintf(stderr, "\n%d-%02d-%02d %02d:%02d:%02d " "Commons Daemon procrun stderr initialized\n", t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); } 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: /* Start service */ if (!docmdStartService(lpCmdline)) rv = 5; break; case 4: /* Stop Service */ if (!docmdStopService(lpCmdline)) rv = 6; break; case 5: /* Update Service parameters */ if (!docmdUpdateService(lpCmdline)) rv = 7; break; case 6: /* Install Service */ if (!docmdInstallService(lpCmdline)) rv = 8; break; case 7: /* Delete Service */ if (!docmdDeleteService(lpCmdline)) rv = 9; break; case 8: /* Print Usage and exit */ printUsage(lpCmdline, TRUE); break; case 9: /* Print version and exit */ printVersion(); break; default: /* Unknown command option */ apxLogWrite(APXLOG_MARK_ERROR "Unknown command line option"); printUsage(lpCmdline, FALSE); rv = 99; break; } cleanup: if (rv) { int ix = 0; if (rv > 0 && rv < 10) ix = rv; apxLogWrite(APXLOG_MARK_ERROR "Commons Daemon procrun failed " "with exit value: %d (Failed to %s)", rv, gSzProc[ix]); if (ix > 2 && !_service_mode) { /* Print something to the user console */ apxDisplayError(FALSE, NULL, 0, "Failed to %s", gSzProc[ix]); } } else apxLogWrite(APXLOG_MARK_INFO "Commons Daemon procrun finished"); if (lpCmdline) apxCmdlineFree(lpCmdline); _service_status_handle = NULL; _service_mode = FALSE; _flushall(); apxLogClose(NULL); apxHandleManagerDestroy(); ExitProcess(rv); } commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.h 0100664 0001750 0001750 00000002401 13006623470 025051 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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@apache.org> * 05 Aug 2003 * ==================================================================== */ #ifndef _PRUNSRV_H #define _PRUNSRV_H #undef PRG_VERSION #define PRG_VERSION "1.1.0.0" #define PRG_REGROOT L"Apache Software Foundation\\Procrun 2.0" #endif /* _PRUNSRV_H */ commons-daemon-1.1.0-native-src/windows/include/console.h 0100664 0001750 0001750 00000001674 10533241454 023750 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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_ */ commons-daemon-1.1.0-native-src/windows/include/cmdline.h 0100664 0001750 0001750 00000005703 13017110374 023712 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 as -- */ #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 szArgv0; 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, LPCWSTR *lpszAltcmds ); void apxCmdlineLoadEnvVars( LPAPXCMDLINE lpCmdline ); void apxCmdlineFree( LPAPXCMDLINE lpCmdline ); __APXEND_DECLS #endif /* _CMDLINE_H_INCLUDED_ */ commons-daemon-1.1.0-native-src/windows/include/apxwin.h 0100664 0001750 0001750 00000014222 13177100456 023610 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 #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 IS_VALID_STRING(s) ((s) != NULL && *(s) != 0) #define IS_EMPTY_STRING(s) ((s) == NULL || *(s) == 0) #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) #define SIZ_PATHLEN 4096 #define SIZ_PATHMAX 4095 #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 LPWSTR AsciiToWide(LPCSTR s, LPWSTR ws); LPSTR MzWideToAscii(LPCWSTR ws, LPSTR s); LPSTR WideToANSI(LPCWSTR ws); LPSTR MzWideToANSI(LPCWSTR ws); typedef struct APXMULTISZ APXMULTISZ; typedef APXMULTISZ* LPAPXMULTISZ; 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 apxAtoulW(LPCWSTR szNum); BOOL apxMakeResourceName(LPCTSTR szPrefix, LPTSTR lpBuff, DWORD dwBuffLength); INT apxStrMatchW(LPCWSTR szString, LPCWSTR szPattern, BOOL bIgnoreCase); INT apxMultiStrMatchW(LPCWSTR szString, LPCWSTR szPattern, WCHAR chSeparator, BOOL bIgnoreCase); void apxStrQuoteInplaceW(LPWSTR szString); LPWSTR apxMszToCRLFW(APXHANDLE hPool, LPCWSTR szStr); LPWSTR apxCRLFToMszW(APXHANDLE hPool, LPCWSTR szStr, LPDWORD lpdwBytes); LPWSTR apxExpandStrW(APXHANDLE hPool, LPCWSTR szString); void apxStrCharReplaceA(LPSTR szString, CHAR chReplace, CHAR chReplaceWith); void apxStrCharReplaceW(LPWSTR szString, WCHAR chReplace, WCHAR chReplaceWith); BOOL apxAddToPathW(APXHANDLE hPool, LPCWSTR szAdd); 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); #define AplMoveMemory AplCopyMemory LPSTR lstrlcatA(LPSTR dst, int siz, LPCSTR src); LPWSTR lstrlcatW(LPWSTR dst, int siz, LPCWSTR src); LPSTR lstrlcpyA(LPSTR dst, int siz, LPCSTR src); LPWSTR lstrlcpyW(LPWSTR dst, int siz, LPCWSTR src); LPWSTR lstrlocaseW(LPWSTR str); PSECURITY_ATTRIBUTES GetNullACL(); void CleanNullACL(void *sa); __APXEND_DECLS #endif /* _APXWIN_H_INCLUDED_ */ commons-daemon-1.1.0-native-src/windows/include/Makefile.inc 0100664 0001750 0001750 00000022512 13177072435 024347 0 ustar 00mark mark 0000000 0000000 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. # # # ==================================================================== # # Makefile.inc Master makefile definitions. # This file defines CPU architecture and basic compiler # and linker parameters. # Common params: # CPU Compile for specified CPU. Supported CPUs are: # X86 (Common x86 architecture) # X64 (AMD64/EMT64 architecture) # If not specified it will default to the # BUILD_CPU environment variable, failing that # It will default to the # PROCESSOR_ARCHITECTURE/ARCHITEW6432 environment variables # or failing that it will default to X86. # WINVER Compile for specified Windows version # WINXP for Windows XP and up (default) # WIN2003 for Windows 2003 and up # VISTA for Windows Vista and up # WIN7 for Windows 7 and up # Deprecated targets (may not even compile): # WINNT for Windows 2000 and up # NT4 for Windows NT4 and up # WIN9X for Windows 95, 98 and Me # BUILD Build version # RETAIL or RELEASE (default) # DEBUG # TARGET Build application target # EXE Console executable (default) # GUI Windows GUI executable # DLL Dynamic Link Library # LIB Static library # Environment variables used: # EXTRA_CFLAGS Added to the common CFLAGS # EXTRA_CXXFLAGS Added to the common CXXFLAGS # EXTRA_LIBS Added to the common LIBS # EXTRA_LFLAGS Added to the common LFLAGS # EXTRA_RCFLAGS Added to the common RCFLAGS # # Compiler tools environment variables: # CC C compiler (defaults to cl.exe) # CXX C++ compiler (defaults to $CC -TP) # CPP C preprocessor (defaults to $CC -EP) # LINK Linker (defaults to link.exe) # RC Resource compiler (defaults to rc.exe) # MT Manifest toolkit (defaults to mt.exe) # ML Assembler (defaults to ml.exe or ml64.exe) # # Originally contributed by Mladen Turk <mturk jboss.com> # # ==================================================================== # # C/C++ compiler !IF !DEFINED(CC) || "$(CC)" == "" CC = cl.exe !ENDIF !IF !DEFINED(CXX) || "$(CXX)" == "" CXX = $(CC) -TP !ENDIF !IF !DEFINED(CPP) || "$(CPP)" == "" CPP = $(CC) -EP !ENDIF # Linker !IF !DEFINED(LINK) || "$(LINK)" == "" LINK = link.exe !ENDIF # Resource Compiler !IF !DEFINED(RC) || "$(RC)" == "" RC = rc.exe !ENDIF # Manifest toolkit !IF !DEFINED(MT) || "$(MT)" == "" MT = mt.exe !ENDIF # If CPU is not defined, apply defaults !IF !DEFINED(CPU) || "$(CPU)" == "" # Set BUILD_CPU if it is not yet set !IF !DEFINED(BUILD_CPU) || "$(BUILD_CPU)" == "" !IF "$(PROCESSOR_ARCHITECTURE)" == "" !IF "$(PROCESSOR_ARCHITEW6432)" == "" # Default to x86, will be upcased later BUILD_CPU=x86 !ELSE BUILD_CPU=$(PROCESSOR_ARCHITEW6432) !ENDIF !ELSE BUILD_CPU=$(PROCESSOR_ARCHITECTURE) !ENDIF !ENDIF # Check BUILD_CPU and reset value if necessary !IF "$(BUILD_CPU)" == "i386" || "$(BUILD_CPU)" == "x86" || "$(BUILD_CPU)" == "i686" CPU=X86 !ENDIF !IF "$(BUILD_CPU)" == "amd64" || "$(BUILD_CPU)" == "x86_64" || "$(BUILD_CPU)" == "x64" CPU=X64 !ENDIF # did we manage to set CPU? !IF !DEFINED(CPU) || "$(CPU)" == "" !ERROR Unexpected value of BUILD_CPU: $(BUILD_CPU) or PROCESSOR_ARCHITECTURE=$(PROCESSOR_ARCHITECTURE) or PROCESSOR_ARCHITEW6432=$(PROCESSOR_ARCHITEW6432). !ENDIF !ENDIF !IF "$(CPU)" != "X86" !IF "$(CPU)" != "X64" !ERROR Must specify CPU environment variable (X86, X64) $(CPU) !ENDIF !ENDIF !IF !DEFINED(TARGET) || "$(TARGET)" == "" TARGET=EXE !ENDIF !IF "$(TARGET)" != "EXE" !IF "$(TARGET)" != "GUI" !IF "$(TARGET)" != "DLL" !IF "$(TARGET)" != "LIB" !ERROR Must specify TARGET environment variable (EXE, GUI, DLL, LIB) !ENDIF !ENDIF !ENDIF !ENDIF !IF !DEFINED(WINVER) || "$(WINVER)" == "" WINVER=WINXP !ENDIF !IF "$(WINVER)" == "WINXP" NMAKE_WINVER = 0x0501 _WIN32_IE = 0x0600 !ELSEIF "$(WINVER)" == "WIN2003" NMAKE_WINVER = 0x0502 _WIN32_IE = 0x0600 !ELSEIF "$(WINVER)" == "VISTA" NMAKE_WINVER = 0x0600 _WIN32_IE = 0x0700 !ELSEIF "$(WINVER)" == "WIN7" NMAKE_WINVER = 0x0700 _WIN32_IE = 0x0800 !ELSE !ERROR Must specify WINVER environment variable (WINXP, WIN2003, VISTA, WIN7) !ENDIF NMAKE_WINNT = -D_WINNT -D_WIN32_WINNT=$(NMAKE_WINVER) -DWINVER=$(NMAKE_WINVER) -D_WIN32_IE=$(_WIN32_IE) !IF !DEFINED(BUILD) || "$(BUILD)" == "" BUILD=RELEASE !ENDIF !IFDEF RELEASE BUILD=RELEASE !ENDIF !IFDEF DEBUG BUILD=DEBUG !ENDIF !IFDEF NODEBUG BUILD=RELEASE !ENDIF !IF "$(BUILD)" != "RELEASE" !IF "$(BUILD)" != "DEBUG" !ERROR Must specify BUILD environment variable (RELEASE, DEBUG) !ENDIF !ENDIF # Common flags for all platforms CMN_CFLAGS = -c -nologo -DWIN32 -D_WIN32 -D_WINDOWS $(NMAKE_WINNT) -W3 !IF "$(TARGET)" == "EXE" CMN_CFLAGS = $(CMN_CFLAGS) -D_CONSOLE !ENDIF # Mark that extern C newer throws C++ exception CMN_CFLAGS = $(CMN_CFLAGS) -EHsc # All supported platforms support unicode CMN_CFLAGS = $(CMN_CFLAGS) -D_UNICODE -DUNICODE !IF "$(CPU)" == "X86" CPU_CFLAGS = -D_X86_=1 MACHINE=X86 MACHINE_LC=i386 !ELSEIF "$(CPU)" == "X64" CPU_CFLAGS = -D_AMD64_=1 -DWIN64 -D_WIN64 MACHINE=AMD64 MACHINE_LC=amd64 !ENDIF !IF "$(BUILD)" == "RELEASE" !IF "$(CPU)" == "X86" OPT_CFLAGS = -O2 -Ob2 -Oy- -Zi -DNDEBUG !ELSE OPT_CFLAGS = -O2 -Ob2 -Zi -DNDEBUG !ENDIF !ELSE OPT_CFLAGS = -Od -Zi -DDEBUG -D_DEBUG !ENDIF !IF DEFINED(STATIC_CRT) CRT_CFLAGS = -D_MT -MT !ELSE CRT_CFLAGS = -D_MT -MD !ENDIF !IF "$(BUILD)" == "DEBUG" CRT_CFLAGS = $(CRT_CFLAGS)d !ENDIF CFLAGS = $(CMN_CFLAGS) $(CPU_CFLAGS) $(OPT_CFLAGS) $(CRT_CFLAGS) !IF DEFINED(EXTRA_CFLAGS) CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS) !ENDIF # Cleanup CXXFLAGS CXXFLAGS = !IF DEFINED(EXTRA_CXXFLAGS) CXXFLAGS = $(EXTRA_CXXFLAGS) !ENDIF # Linker section LIBS = kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib # Extra libs from command line or env !IF DEFINED(EXTRA_LIBS) LIBS = $(LIBS) $(EXTRA_LIBS) !ENDIF # Run-Time Error Checks !IF "$(BUILD)" == "DEBUG" !IF DEFINED(RTC_CHECK) LIBS = $(LIBS) RunTmChk.lib CFLAGS = $(CFLAGS) -RTC1 !ENDIF !ENDIF COMMON_LFLAGS = /NOLOGO # Always add debugging to the linker OPT_LFLAGS = /INCREMENTAL:NO /DEBUG !IF "$(BUILD)" == "RELEASE" OPT_LFLAGS = /OPT:REF !ENDIF !IF "$(TARGET)" == "EXE" LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(MACHINE) !ELSEIF "$(TARGET)" == "GUI" LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:WINDOWS /MACHINE:$(MACHINE) !ELSEIF "$(TARGET)" == "DLL" LFLAGS = $(COMMON_LFLAGS) /DLL /SUBSYSTEM:WINDOWS /MACHINE:$(MACHINE) !ELSEIF "$(TARGET)" == "LIB" LFLAGS = -lib $(COMMON_LFLAGS) !ENDIF !IF DEFINED(EXTRA_LFLAGS) LFLAGS = $(LFLAGS) $(EXTRA_LFLAGS) !ENDIF !IF "$(TARGET)" != "LIB" LFLAGS = $(LFLAGS) $(OPT_LFLAGS) !ENDIF # Resource compiler flags RCFLAGS=/l 0x409 !IF "$(BUILD)" == "RELEASE" RCFLAGS = $(RCFLAGS) /d "NDEBUG" !ELSE RCFLAGS = $(RCFLAGS) /d "_DEBUG" /d "DEBUG" !ENDIF RCFLAGS = $(RCFLAGS) !IF DEFINED(EXTRA_RCFLAGS) RCFLAGS = $(RCFLAGS) $(EXTRA_RCFLAGS) !ENDIF # Build Target dir e.g. WINNT_I386_RELEASE_DLL !IF !DEFINED(WORKDIR) || "$(WORKDIR)" == "" !IF !DEFINED(WORKDIR_EXT) || "$(WORKDIR_EXT)" == "" WORKDIR = $(WINVER)_$(CPU)_$(TARGET)_$(BUILD) WORKDIR_DLL = $(WINVER)_$(CPU)_DLL_$(BUILD) WORKDIR_LIB = $(WINVER)_$(CPU)_LIB_$(BUILD) WORKDIR_EXE = $(WINVER)_$(CPU)_EXE_$(BUILD) !ELSE WORKDIR = $(WINVER)_$(CPU)_$(BUILDIR_EXT)_$(BUILD) !ENDIF !ENDIF CLEANTARGET=if exist "$(WORKDIR)\$(NULL)" rd /s /q $(WORKDIR) MAKEWORKDIR=if not exist "$(WORKDIR)\$(NULL)" mkdir $(WORKDIR) MAKEINSTALL=if not exist "$(INSTALLLOC)\$(NULL)" mkdir $(INSTALLLOC) !IF DEFINED(JAVA_HOME) && "$(JAVA_HOME)" != "" JAVA_INCLUDES=-I "$(JAVA_HOME)\include" -I "$(JAVA_HOME)\include\win32" !ENDIF # Assembler Section !IF !DEFINED(ML) || "$(ML)" == "" !IF "$(CPU)" == "X86" ML = ml.exe AFLAGS = /coff /Zi /c !ELSEIF "$(CPU)" == "X64" ML = ml64.exe AFLAGS = /Zi /c !ENDIF !ENDIF commons-daemon-1.1.0-native-src/windows/include/javajni.h 0100664 0001750 0001750 00000005300 13200310526 023705 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 #define APX_JVM_DESTROY 0x00000001 typedef struct stAPXJAVA_THREADARGS { LPVOID hJava; LPCSTR szClassPath; LPCVOID lpOptions; LPCVOID lpOptions9; DWORD dwMs; DWORD dwMx; DWORD dwSs; DWORD bJniVfprintf; LPCSTR szClassName; LPCSTR szMethodName; LPCVOID lpArguments; BOOL setErrorOrOut; LPCWSTR szStdErrFilename; LPCWSTR szStdOutFilename; LPCWSTR szLibraryPath; } APXJAVA_THREADARGS, *LPAPXJAVA_THREADARGS; APXHANDLE apxCreateJava(APXHANDLE hPool, LPCWSTR szJvmDllPath); BOOL apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath, LPCVOID lpOptions, LPCVOID lpOptions9, DWORD dwMs, DWORD dwMx, DWORD dwSs, DWORD bJniVfprintf); DWORD apxJavaCmdInitialize(APXHANDLE hPool, LPCWSTR szClassPath, LPCWSTR szClass, LPCWSTR szOptions, DWORD dwMs, DWORD dwMx, DWORD dwSs, LPCWSTR szCmdArgs, LPWSTR **lppArray); BOOL apxJavaLoadMainClass(APXHANDLE hJava, LPCSTR szClassName, LPCSTR szMethodName, LPCVOID lpArguments); BOOL apxJavaStart(LPAPXJAVA_THREADARGS pArgs); DWORD apxJavaWait(APXHANDLE hJava, DWORD dwMilliseconds, BOOL bKill); BOOL apxJavaSetOut(APXHANDLE hJava, BOOL setErrorOrOut, LPCWSTR szFilename); DWORD apxJavaSetOptions(APXHANDLE hJava, DWORD dwOptions); BOOL apxDestroyJvm(DWORD dwTimeout); DWORD apxGetVmExitCode(); void apxSetVmExitCode(DWORD exitCode); void apxJavaDumpAllStacks(APXHANDLE hJava); __APXEND_DECLS #endif /* _JAVAJNI_H_INCLUDED_ */ commons-daemon-1.1.0-native-src/windows/include/gui.h 0100664 0001750 0001750 00000012472 13177075725 023105 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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); 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 apxBrowseForFolderW(HWND hWnd, LPCWSTR szTitle, LPCWSTR szName); LPWSTR apxGetFileNameW(HWND hWnd, LPCWSTR szTitle, LPCWSTR szFilter, LPCWSTR szDefExt, LPCWSTR szDefPath, BOOL bOpenOrSave, LPDWORD lpdwFindex); LPCWSTR apxDlgSelectUser(HWND hWnd, LPWSTR szUser); __APXEND_DECLS #endif /* _GUI_H_INCLUDED_ */ commons-daemon-1.1.0-native-src/windows/include/handles.h 0100664 0001750 0001750 00000014207 13177061204 023720 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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); /** General system pool memory allocation functions */ LPVOID apxAlloc(DWORD dwSize); LPVOID apxCalloc(DWORD dwSize); LPVOID apxRealloc(LPVOID lpMem, DWORD dwNewSize); LPWSTR apxStrdupW(LPCWSTR szSource); LPWSTR apxPoolStrdupW(APXHANDLE hPool, LPCWSTR szSource); /** 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_ */ commons-daemon-1.1.0-native-src/windows/include/service.h 0100664 0001750 0001750 00000005762 10577252420 023753 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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); DWORD apxGetMaxServiceTimeout(APXHANDLE hPool); __APXEND_DECLS #endif /* _SERVICE_H_INCLUDED_ */ commons-daemon-1.1.0-native-src/windows/include/registry.h 0100664 0001750 0001750 00000007012 13177034332 024150 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 apxCreateRegistryW(APXHANDLE hPool, REGSAM samDesired, LPCWSTR szRoot, LPCWSTR szKeyName, DWORD dwOptions); /** Delete the process registry keys * samDesired only needs to be KREG_WOW6432 or 0 */ BOOL apxDeleteRegistryW(LPCWSTR szRoot, LPCWSTR szKeyName, REGSAM samDesired, BOOL bDeleteEmptyRoot); /** 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); LPWSTR apxRegistryGetStringW(APXHANDLE hRegistry, DWORD dwFrom, LPCWSTR szSubkey, LPCWSTR szValueName); 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 apxRegistrySetStrW(APXHANDLE hRegistry, DWORD dwFrom, LPCWSTR szSubkey, LPCWSTR szValueName, LPCWSTR szValue); 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); __APXEND_DECLS #endif /* _REGISTRY_H_INCLUDED_ */ commons-daemon-1.1.0-native-src/windows/include/log.h 0100664 0001750 0001750 00000006507 13017110374 023063 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 APX_LOGENTER() \ if (_pt_sys_loglock) \ EnterCriticalSection(_pt_sys_loglock); \ else (void)0 #define APX_LOGLEAVE() \ if (_pt_sys_loglock) \ LeaveCriticalSection(_pt_sys_loglock); \ else (void)0 #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, __FILE__, __LINE__, "" #define APXLOG_MARK_WARN NULL, APXLOG_LEVEL_WARN, TRUE, __FILE__, __LINE__, "" #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, BOOL bTimeStamp, DWORD dwRotate ); HANDLE apxLogOpen( APXHANDLE hPool, LPCWSTR szPath, LPCWSTR szPrefix, DWORD dwRotate ); 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_ */ commons-daemon-1.1.0-native-src/windows/include/rprocess.h 0100664 0001750 0001750 00000004015 13177060767 024153 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 apxCreateProcessW(APXHANDLE hPool, DWORD dwOptions, LPAPXFNCALLBACK fnCallback, LPCWSTR szUsername, LPCWSTR szPassword, BOOL bLogonAsService); BOOL apxProcessSetExecutableW(APXHANDLE hProcess, LPCWSTR szName); BOOL apxProcessSetCommandLineW(APXHANDLE hProcess, LPCWSTR szCmdline); BOOL apxProcessSetCommandArgsW(APXHANDLE hProcess, LPCWSTR szTitle, DWORD dwArgc, LPCWSTR *lpArgs); BOOL apxProcessSetWorkingPathW(APXHANDLE hProcess, LPCWSTR szPath); 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); DWORD apxProcessGetPid(APXHANDLE hProcess); __APXEND_DECLS #endif /* _RPROCESS_H_INCLUDED_ */ commons-daemon-1.1.0-native-src/windows/resources/license.rtf 0100664 0001750 0001750 00000013100 13127316537 024655 0 ustar 00mark mark 0000000 0000000 {\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-2017 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 }} commons-daemon-1.1.0-native-src/windows/xdocs/index.xml 0100664 0001750 0001750 00000002211 11340661046 023447 0 ustar 00mark mark 0000000 0000000 <?xml version="1.0"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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. --> <document> <properties> <title>Daemon : Procrun</title> <author email="mturk@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> commons-daemon-1.1.0-native-src/windows/src/javajni.c 0100664 0001750 0001750 00000125107 13200310526 023054 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "handles.h" #include "javajni.h" #include "private.h" #include <jni.h> #ifndef JNI_VERSION_1_6 #error ------------------------------------------------------- #error JAVA 5 AND EARLIER ARE NO LONGER SUPPORTED #error ------------------------------------------------------- #endif #define JNI_VERSION_DEFAULT JNI_VERSION_1_6 /* Need to be able to detect Java 9 without requiring compilation against Java 9 * headers. */ #ifndef JNI_VERSION_9 #define JNI_VERSION_9 0x00090000 #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; DYNOLAD_TYPE_DECLARE(JVM_DumpAllStacks, JNICALL, void)(JNIEnv *, jclass); static DYNLOAD_FPTR_DECLARE(JVM_DumpAllStacks) = NULL; static HANDLE _st_sys_jvmDllHandle = NULL; static JavaVM *_st_sys_jvm = NULL; DYNOLAD_TYPE_DECLARE(SetDllDirectoryW, WINAPI, BOOL)(LPCWSTR); static DYNLOAD_FPTR_DECLARE(SetDllDirectoryW) = 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) #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 #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 { CHAR sClazz[1024]; CHAR sMethod[512]; 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; SIZE_T szStackSize; HANDLE hWorkerSync; HANDLE hWorkerInit; } APXJAVAVM, *LPAPXJAVAVM; /* This is no longer exported in jni.h * However Java uses it internally to get * the default stack size */ typedef struct APX_JDK1_1InitArgs { jint version; char **properties; jint checkSource; jint nativeStackSize; jint javaStackSize; jint minHeapSize; jint maxHeapSize; jint verifyMode; char *classpath; char padding[128]; } APX_JDK1_1InitArgs; #define JAVA_CLASSPATH "-Djava.class.path=" #define JAVA_CLASSPATH_W L"-Djava.class.path=" #define JAVA_CLASSSTRING "java/lang/String" #define MSVCRT71_DLLNAME L"\\msvcrt71.dll" static DWORD vmExitCode = 0; static __inline BOOL __apxJvmAttachEnv(LPAPXJAVAVM lpJava, JNIEnv **lpEnv, LPBOOL lpAttached) { jint _iStatus; if (!_st_sys_jvm || !lpJava->lpJvm) return FALSE; _iStatus = (*(lpJava->lpJvm))->GetEnv(lpJava->lpJvm, (void **)lpEnv, lpJava->iVersion); if (_iStatus != JNI_OK) { if (_iStatus == JNI_EDETACHED) { _iStatus = (*(lpJava->lpJvm))->AttachCurrentThread(lpJava->lpJvm, (void **)lpEnv, NULL); if (lpAttached) *lpAttached = TRUE; } } if (_iStatus != JNI_OK) { *lpEnv = NULL; return FALSE; } else return TRUE; } static __inline BOOL __apxJvmAttach(LPAPXJAVAVM lpJava) { return __apxJvmAttachEnv(lpJava, &lpJava->lpEnv, NULL); } static __inline BOOL __apxJvmDetach(LPAPXJAVAVM lpJava) { if (!_st_sys_jvm || !lpJava->lpJvm) return FALSE; if ((*(lpJava->lpJvm))->DetachCurrentThread(lpJava->lpJvm) != JNI_OK) { lpJava->lpEnv = NULL; return FALSE; } else return TRUE; } static BOOL __apxLoadJvmDll(LPCWSTR szJvmDllPath) { UINT errMode; WCHAR jreAltPath[SIZ_PATHLEN]; LPWSTR dllJvmPath = (LPWSTR)szJvmDllPath; DYNLOAD_FPTR_DECLARE(SetDllDirectoryW); if (!IS_INVALID_HANDLE(_st_sys_jvmDllHandle)) return TRUE; /* jvm.dll is already loaded */ if (dllJvmPath && *dllJvmPath) { /* Explicit JVM path. * Check if provided argument is valid */ if (GetFileAttributesW(dllJvmPath) == INVALID_FILE_ATTRIBUTES) { /* DAEMON-247: Invalid RuntimeLib explicitly specified is error. */ apxLogWrite(APXLOG_MARK_DEBUG "Invalid RuntimeLib specified '%S'", dllJvmPath); return FALSE; } } else { dllJvmPath = apxGetJavaSoftRuntimeLib(NULL); if (!dllJvmPath) return FALSE; } if (GetFileAttributesW(dllJvmPath) == INVALID_FILE_ATTRIBUTES) { /* DAEMON-184: RuntimeLib registry key is invalid. * Check from Jre JavaHome directly */ LPWSTR szJreHome = apxGetJavaSoftHome(NULL, TRUE); apxLogWrite(APXLOG_MARK_DEBUG "Invalid RuntimeLib '%S'", dllJvmPath); if (szJreHome) { apxLogWrite(APXLOG_MARK_DEBUG "Using Jre JavaHome '%S'", szJreHome); lstrlcpyW(jreAltPath, SIZ_PATHLEN, szJreHome); lstrlcatW(jreAltPath, SIZ_PATHLEN, L"\\bin\\server\\jvm.dll"); dllJvmPath = jreAltPath; } } /* Suppress the not found system popup message */ errMode = SetErrorMode(SEM_FAILCRITICALERRORS); apxLogWrite(APXLOG_MARK_DEBUG "loading jvm '%S'", dllJvmPath); _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL, 0); if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle) && GetFileAttributesW(dllJvmPath) != INVALID_FILE_ATTRIBUTES) { /* There is a file but cannot be loaded. * Try to load the MSVCRTxx.dll before JVM.dll */ WCHAR jreBinPath[SIZ_PATHLEN]; WCHAR crtBinPath[SIZ_PATHLEN]; DWORD i, l = 0; lstrlcpyW(jreBinPath, SIZ_PATHLEN, dllJvmPath); for (i = lstrlenW(jreBinPath); i > 0, l < 2; i--) { if (jreBinPath[i] == L'\\' || jreBinPath[i] == L'/') { jreBinPath[i] = L'\0'; lstrlcpyW(crtBinPath, SIZ_PATHLEN, jreBinPath); lstrlcatW(crtBinPath, SIZ_PATHLEN, MSVCRT71_DLLNAME); if (GetFileAttributesW(crtBinPath) != INVALID_FILE_ATTRIBUTES) { if (LoadLibraryW(crtBinPath)) { /* Found MSVCRTxx.dll */ apxLogWrite(APXLOG_MARK_DEBUG "preloaded '%S'", crtBinPath); break; } } l++; } } } /* 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); if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle)) { WCHAR jreBinPath[SIZ_PATHLEN]; DWORD i, l = 0; lstrlcpyW(jreBinPath, SIZ_PATHLEN, dllJvmPath); DYNLOAD_FPTR_ADDRESS(SetDllDirectoryW, KERNEL32); for (i = lstrlenW(jreBinPath); i > 0, l < 2; i--) { if (jreBinPath[i] == L'\\' || jreBinPath[i] == L'/') { jreBinPath[i] = L'\0'; DYNLOAD_CALL(SetDllDirectoryW)(jreBinPath); apxLogWrite(APXLOG_MARK_DEBUG "Setting DLL search path to '%S'", jreBinPath); l++; } } _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL, 0); 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); DYNLOAD_FPTR_LOAD(JVM_DumpAllStacks, _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 (_st_sys_jvm && 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) { /* 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; struct APX_JDK1_1InitArgs jArgs1_1; 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; /* Guess the stack size */ AplZeroMemory(&jArgs1_1, sizeof(jArgs1_1)); jArgs1_1.version = JNI_VERSION_1_1; DYNLOAD_FPTR(JNI_GetDefaultJavaVMInitArgs)(&jArgs1_1); if (jArgs1_1.javaStackSize < 0 || jArgs1_1.javaStackSize > (2048 * 1024)) jArgs1_1.javaStackSize = 0; lpJava->szStackSize = (SIZE_T)jArgs1_1.javaStackSize; if (!_st_sys_jvm) _st_sys_jvm = lpJvm; return hJava; } static DWORD WINAPI __apxJavaDestroyThread(LPVOID lpParameter) { JavaVM *lpJvm = (JavaVM *)lpParameter; (*lpJvm)->DestroyJavaVM(lpJvm); return 0; } BOOL apxDestroyJvm(DWORD dwTimeout) { if (_st_sys_jvm) { DWORD tid; HANDLE hWaiter; BOOL rv = FALSE; JavaVM *lpJvm = _st_sys_jvm; _st_sys_jvm = NULL; (*lpJvm)->DetachCurrentThread(lpJvm); hWaiter = CreateThread(NULL, 0, __apxJavaDestroyThread, (void *)lpJvm, 0, &tid); if (IS_INVALID_HANDLE(hWaiter)) { apxLogWrite(APXLOG_MARK_SYSERR); return FALSE; } if (WaitForSingleObject(hWaiter, dwTimeout) == WAIT_OBJECT_0) rv = TRUE; CloseHandle(hWaiter); return rv; } else return FALSE; } static BOOL __apxIsJava9() { JavaVMInitArgs vmArgs; vmArgs.version = JNI_VERSION_9; /* Returns an error if requested version is not supported */ if (DYNLOAD_FPTR(JNI_GetDefaultJavaVMInitArgs)(&vmArgs) != JNI_OK) { return FALSE; } else { return TRUE; } } static DWORD __apxMultiSzToJvmOptions(APXHANDLE hPool, LPCSTR lpString, LPCSTR lpString9, JavaVMOption **lppArray, DWORD nExtra) { DWORD i, n = 0, n9 = 0, nTotal, l = 0, l9 = 0, lTotal; char *buff; LPSTR p; if (lpString) { l = __apxGetMultiSzLengthA(lpString, &n); } if (__apxIsJava9() && lpString9) { l9 = __apxGetMultiSzLengthA(lpString9, &n9); } nTotal = n + n9 + nExtra; lTotal = l + l9; buff = apxPoolAlloc(hPool, (nTotal + 1) * sizeof(JavaVMOption) + (lTotal + 1)); *lppArray = (JavaVMOption *)buff; p = (LPSTR)(buff + (nTotal + 1) * sizeof(JavaVMOption)); if (lpString) AplCopyMemory(p, lpString, l + 1); for (i = 0; i < n; i++) { DWORD qr = apxStrUnQuoteInplaceA(p); (*lppArray)[i].optionString = p; while (*p) p++; p++; p += qr; } if (lpString9) AplCopyMemory(p, lpString9, l9 + 1); for (i = n; i < (n + n9); i++) { DWORD qr = apxStrUnQuoteInplaceA(p); (*lppArray)[i].optionString = p; while (*p) p++; p++; p += qr; } return nTotal; } /* 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); if (apxLogWrite(APXLOG_MARK_INFO "%s", sBuf) == 0) fputs(sBuf, stdout); return rv; } static void JNICALL __apxJniExit(jint exitCode) { apxLogWrite(APXLOG_MARK_DEBUG "Exit hook with exit code %d", exitCode); vmExitCode = exitCode; return; } static void JNICALL __apxJniAbort() { apxLogWrite(APXLOG_MARK_DEBUG "JVM aborted"); // Set the exit code to a non-zero value to indicate a non-standard exit vmExitCode = 1; return; } static LPSTR __apxStrIndexA(LPCSTR szStr, int nCh) { LPSTR pStr; for (pStr = (LPSTR)szStr; *pStr; pStr++) { if (*pStr == nCh) return pStr; } return NULL; } static LPSTR __apxStrnCatA(APXHANDLE hPool, LPSTR pOrg, LPCSTR szStr, LPCSTR szAdd) { DWORD len = 1; DWORD nas = pOrg == NULL; if (pOrg) len += lstrlenA(pOrg); if (szStr) len += lstrlenA(szStr); if (szAdd) len += lstrlenA(szAdd); pOrg = (LPSTR)apxPoolRealloc(hPool, pOrg, len); if (pOrg) { if (nas) *pOrg = '\0'; if (szStr) lstrcatA(pOrg, szStr); if (szAdd) lstrcatA(pOrg, szAdd); } return pOrg; } static LPSTR __apxEvalPathPart(APXHANDLE hPool, LPSTR pStr, LPCSTR szPattern) { HANDLE hFind; WIN32_FIND_DATAA stGlob; char szJars[MAX_PATH + 1]; char szPath[MAX_PATH + 1]; if (lstrlenA(szPattern) > (sizeof(szJars) - 5)) { return __apxStrnCatA(hPool, pStr, szPattern, NULL); } lstrcpyA(szJars, szPattern); szPath[0] = ';'; szPath[1] = '\0'; lstrcatA(szPath, szPattern); lstrcatA(szJars, ".jar"); /* Remove the trailing asterisk */ szPath[lstrlenA(szPath) - 1] = '\0'; if ((hFind = FindFirstFileA(szJars, &stGlob)) == INVALID_HANDLE_VALUE) { /* Find failed */ return pStr; } pStr = __apxStrnCatA(hPool, pStr, &szPath[1], stGlob.cFileName); if (pStr == NULL) { FindClose(hFind); return NULL; } while (FindNextFileA(hFind, &stGlob) != 0) { pStr = __apxStrnCatA(hPool, pStr, szPath, stGlob.cFileName); if (pStr == NULL) break; } FindClose(hFind); return pStr; } /** * Call glob on each PATH like string path. * Glob is called only if the part ends with asterisk in which * case asterisk is replaced by *.jar when searching */ static LPSTR __apxEvalClasspath(APXHANDLE hPool, LPCSTR szCp) { LPSTR pCpy = __apxStrnCatA(hPool, NULL, JAVA_CLASSPATH, szCp); LPSTR pGcp = NULL; LPSTR pPos; LPSTR pPtr; if (!pCpy) return NULL; pPtr = pCpy + sizeof(JAVA_CLASSPATH) - 1; while ((pPos = __apxStrIndexA(pPtr, ';'))) { *pPos = '\0'; if (pGcp) pGcp = __apxStrnCatA(hPool, pGcp, ";", NULL); else pGcp = __apxStrnCatA(hPool, NULL, JAVA_CLASSPATH, NULL); if ((pPos > pPtr) && (*(pPos - 1) == '*')) { if (!(pGcp = __apxEvalPathPart(hPool, pGcp, pPtr))) { /* Error. * Return the original string processed so far. */ return pCpy; } } else { /* Standard path element */ if (!(pGcp = __apxStrnCatA(hPool, pGcp, pPtr, NULL))) { /* Error. * Return the original string processed so far. */ return pCpy; } } pPtr = pPos + 1; } if (*pPtr) { int end = lstrlenA(pPtr); if (pGcp) pGcp = __apxStrnCatA(hPool, pGcp, ";", NULL); else pGcp = __apxStrnCatA(hPool, NULL, JAVA_CLASSPATH, NULL); if (end > 0 && pPtr[end - 1] == '*') { /* Last path elemet ends with star * Do a globbing. */ pGcp = __apxEvalPathPart(hPool, pGcp, pPtr); } else { /* Just add the part */ pGcp = __apxStrnCatA(hPool, pGcp, pPtr, NULL); } } /* Free the allocated copy */ if (pGcp) { apxFree(pCpy); return pGcp; } else return pCpy; } /* ANSI version only */ BOOL apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath, LPCVOID lpOptions, LPCVOID lpOptions9, DWORD dwMs, DWORD dwMx, DWORD dwSs, DWORD bJniVfprintf) { LPAPXJAVAVM lpJava; JavaVMInitArgs vmArgs; JavaVMOption *lpJvmOptions; DWORD i, nOptions, sOptions = 0; 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_6) { apxLogWrite(APXLOG_MARK_ERROR "Unable To Attach the JVM"); return FALSE; } else lpJava->iVersion = JNI_VERSION_1_6; 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_6) { apxLogWrite(APXLOG_MARK_ERROR "Unsupported JNI version %#08x", lpJava->iVersion); return FALSE; } rv = TRUE; } else { CHAR iB[3][64]; LPSTR szCp = NULL; lpJava->iVersion = JNI_VERSION_DEFAULT; if (dwMs) ++sOptions; if (dwMx) ++sOptions; if (dwSs) ++sOptions; if (bJniVfprintf) ++sOptions; if (szClassPath && *szClassPath) ++sOptions; sOptions++; /* unconditionally set for extraInfo exit */ sOptions++; /* unconditionally set for extraInfo abort */ nOptions = __apxMultiSzToJvmOptions(hJava->hPool, lpOptions, lpOptions9, &lpJvmOptions, sOptions); if (szClassPath && *szClassPath) { szCp = __apxEvalClasspath(hJava->hPool, szClassPath); if (szCp == NULL) { apxLogWrite(APXLOG_MARK_ERROR "Invalid classpath %s", szClassPath); return FALSE; } lpJvmOptions[nOptions - sOptions].optionString = szCp; --sOptions; } if (bJniVfprintf) { /* default JNI error printer */ lpJvmOptions[nOptions - sOptions].optionString = "vfprintf"; lpJvmOptions[nOptions - sOptions].extraInfo = __apxJniVfprintf; --sOptions; } /* unconditionally add hook for System.exit() in order to store exit code */ lpJvmOptions[nOptions - sOptions].optionString = "exit"; lpJvmOptions[nOptions - sOptions].extraInfo = __apxJniExit; --sOptions; /* unconditionally add hook for abort in order to store exit code */ lpJvmOptions[nOptions - sOptions].optionString = "abort"; lpJvmOptions[nOptions - sOptions].extraInfo = __apxJniAbort; --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; if (!_st_sys_jvm) _st_sys_jvm = lpJava->lpJvm; } apxFree(szCp); apxFree(lpJvmOptions); } if (rv) return TRUE; else return FALSE; } /* ANSI version only */ DWORD apxJavaCmdInitialize(APXHANDLE hPool, LPCWSTR szClassPath, LPCWSTR szClass, LPCWSTR szOptions, DWORD dwMs, DWORD dwMx, DWORD dwSs, LPCWSTR szCmdArgs, LPWSTR **lppArray) { DWORD i, nJVM, nCmd, nTotal, lJVM, lCmd; LPWSTR p; /* Calculate the number of all arguments */ nTotal = 0; if (szClassPath) ++nTotal; if (szClass) ++nTotal; lJVM = __apxGetMultiSzLengthW(szOptions, &nJVM); nTotal += nJVM; lCmd = __apxGetMultiSzLengthW(szCmdArgs, &nCmd); nTotal += nCmd; if (dwMs) ++nTotal; if (dwMx) ++nTotal; if (dwSs) ++nTotal; if (nTotal == 0) return 0; /* Allocate the array to store all arguments' pointers */ *lppArray = (LPWSTR *)apxPoolAlloc(hPool, (nTotal + 2) * sizeof(LPWSTR)); /* Process JVM options */ if (nJVM && lJVM) { p = (LPWSTR)apxPoolAlloc(hPool, (lJVM + 1) * sizeof(WCHAR)); AplCopyMemory(p, szOptions, (lJVM + 1) * sizeof(WCHAR) + sizeof(WCHAR)); for (i = 0; i < nJVM; i++) { (*lppArray)[i] = p; while (*p) p++; p++; } } /* Process the 3 extra JVM options */ if (dwMs) { p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR)); wsprintfW(p, L"-Xms%dm", dwMs); (*lppArray)[i++] = p; } if (dwMx) { p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR)); wsprintfW(p, L"-Xmx%dm", dwMx); (*lppArray)[i++] = p; } if (dwSs) { p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR)); wsprintfW(p, L"-Xss%dk", dwSs); (*lppArray)[i++] = p; } /* Process the classpath and class */ if (szClassPath) { p = (LPWSTR)apxPoolAlloc(hPool, (lstrlenW(JAVA_CLASSPATH_W) + lstrlenW(szClassPath)) * sizeof(WCHAR)); lstrcpyW(p, JAVA_CLASSPATH_W); lstrcatW(p, szClassPath); (*lppArray)[i++] = p; } if (szClass) { p = (LPWSTR)apxPoolAlloc(hPool, (lstrlenW(szClass)) * sizeof(WCHAR)); lstrcpyW(p, szClass); (*lppArray)[i++] = p; } /* Process command arguments */ if (nCmd && lCmd) { p = (LPWSTR)apxPoolAlloc(hPool, (lCmd + 1) * sizeof(WCHAR)); AplCopyMemory(p, szCmdArgs, (lCmd + 1) * sizeof(WCHAR) + sizeof(WCHAR)); for (; i < nTotal; i++) { (*lppArray)[i] = p; while (*p) p++; p++; } } (*lppArray)[++i] = NULL; return nTotal; } BOOL apxJavaLoadMainClass(APXHANDLE hJava, LPCSTR szClassName, LPCSTR szMethodName, LPCVOID lpArguments) { LPWSTR *lpArgs = NULL; DWORD nArgs; LPAPXJAVAVM lpJava; jclass jClazz; LPCSTR szSignature = "([Ljava/lang/String;)V"; if (hJava->dwType != APXHANDLE_TYPE_JVM) return FALSE; lpJava = APXHANDLE_DATA(hJava); if (!lpJava) return FALSE; if (IS_EMPTY_STRING(szMethodName)) szMethodName = "main"; if (lstrcmpA(szClassName, "java/lang/System") == 0) { /* Usable only for exit method, so force */ szSignature = "(I)V"; szMethodName = "exit"; } lstrlcpyA(lpJava->clWorker.sClazz, 1024, szClassName); lstrlcpyA(lpJava->clWorker.sMethod, 512, szMethodName); jClazz = JNICALL_1(FindClass, JAVA_CLASSSTRING); if (!jClazz) { JVM_EXCEPTION_CLEAR(lpJava); apxLogWrite(APXLOG_MARK_ERROR "FindClass " JAVA_CLASSSTRING " failed"); return FALSE; } lpJava->clString.jClazz = JNICALL_1(NewGlobalRef, jClazz); JNI_LOCAL_UNREF(jClazz); /* 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); lpJava->clWorker.jMethod = JNICALL_3(GetStaticMethodID, lpJava->clWorker.jClazz, szMethodName, szSignature); if (!lpJava->clWorker.jMethod) { JVM_EXCEPTION_CLEAR(lpJava); apxLogWrite(APXLOG_MARK_ERROR "Method 'static void %s(String[])' not found in Class %s", szMethodName, szClassName); return FALSE; } if (lstrcmpA(szClassName, "java/lang/System")) { nArgs = apxMultiSzToArrayW(hJava->hPool, lpArguments, &lpArgs); lpJava->clWorker.jArgs = JNICALL_3(NewObjectArray, nArgs, lpJava->clString.jClazz, NULL); if (nArgs) { DWORD i; for (i = 0; i < nArgs; i++) { jstring arg = JNICALL_2(NewString, lpArgs[i], lstrlenW(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) do { rv = x; goto finished; } while(0) DWORD rv = 0; LPAPXJAVAVM lpJava = NULL; LPAPXJAVA_THREADARGS pArgs = (LPAPXJAVA_THREADARGS)lpParameter; APXHANDLE hJava; hJava = (APXHANDLE)pArgs->hJava; if (hJava->dwType != APXHANDLE_TYPE_JVM) WORKER_EXIT(1); lpJava = APXHANDLE_DATA(pArgs->hJava); if (!lpJava) WORKER_EXIT(1); if (!apxJavaInitialize(pArgs->hJava, pArgs->szClassPath, pArgs->lpOptions, pArgs->lpOptions9, pArgs->dwMs, pArgs->dwMx, pArgs->dwSs, pArgs->bJniVfprintf)) { WORKER_EXIT(2); } if (pArgs->szLibraryPath && *pArgs->szLibraryPath) { DYNLOAD_FPTR_ADDRESS(SetDllDirectoryW, KERNEL32); DYNLOAD_CALL(SetDllDirectoryW)(pArgs->szLibraryPath); apxLogWrite(APXLOG_MARK_DEBUG "DLL search path set to '%S'", pArgs->szLibraryPath); } if (!apxJavaLoadMainClass(pArgs->hJava, pArgs->szClassName, pArgs->szMethodName, pArgs->lpArguments)) { WORKER_EXIT(3); } apxJavaSetOut(pArgs->hJava, TRUE, pArgs->szStdErrFilename); apxJavaSetOut(pArgs->hJava, FALSE, pArgs->szStdOutFilename); /* Check if we have a class and a method */ if (!lpJava->clWorker.jClazz || !lpJava->clWorker.jMethod) WORKER_EXIT(4); if (!__apxJvmAttach(lpJava)) WORKER_EXIT(5); apxLogWrite(APXLOG_MARK_DEBUG "Java Worker thread started %s:%s", lpJava->clWorker.sClazz, lpJava->clWorker.sMethod); lpJava->dwWorkerStatus = 1; SetEvent(lpJava->hWorkerInit); /* Ensure apxJavaStart worker has read our status */ WaitForSingleObject(lpJava->hWorkerSync, INFINITE); JNICALL_3(CallStaticVoidMethod, lpJava->clWorker.jClazz, lpJava->clWorker.jMethod, lpJava->clWorker.jArgs); if (JVM_EXCEPTION_CHECK(lpJava)) { apxLogWrite(APXLOG_MARK_DEBUG "Exception has been thrown"); vmExitCode = 1; (*((lpJava)->lpEnv))->ExceptionDescribe((lpJava)->lpEnv); __apxJvmDetach(lpJava); WORKER_EXIT(6); } else { __apxJvmDetach(lpJava); } finished: if (lpJava) { lpJava->dwWorkerStatus = 0; apxLogWrite(APXLOG_MARK_DEBUG "Java Worker thread finished %s:%s with status = %d", lpJava->clWorker.sClazz, lpJava->clWorker.sMethod, rv); SetEvent(lpJava->hWorkerInit); } ExitThread(rv); /* never gets here but keep the compiler happy */ return rv; } BOOL apxJavaStart(LPAPXJAVA_THREADARGS pArgs) { LPAPXJAVAVM lpJava; lpJava = APXHANDLE_DATA(pArgs->hJava); if (!lpJava) return FALSE; lpJava->dwWorkerStatus = 0; lpJava->hWorkerInit = CreateEvent(NULL, FALSE, FALSE, NULL); lpJava->hWorkerSync = CreateEvent(NULL, FALSE, FALSE, NULL); lpJava->hWorkerThread = CreateThread(NULL, lpJava->szStackSize, __apxJavaWorkerThread, pArgs, CREATE_SUSPENDED, &lpJava->iWorkerThread); if (IS_INVALID_HANDLE(lpJava->hWorkerThread)) { apxLogWrite(APXLOG_MARK_SYSERR); return FALSE; } ResumeThread(lpJava->hWorkerThread); /* Wait until the worker thread initializes */ WaitForSingleObject(lpJava->hWorkerInit, INFINITE); if (lpJava->dwWorkerStatus == 0) return FALSE; SetEvent(lpJava->hWorkerSync); if (lstrcmpA(lpJava->clWorker.sClazz, "java/lang/System")) { /* Give some time to initialize the thread * Unless we are calling System.exit(0). * This will be handled by _onexit hook. */ Sleep(1000); } return TRUE; } DWORD apxJavaSetOptions(APXHANDLE hJava, DWORD dwOptions) { DWORD dwOrgOptions; LPAPXJAVAVM lpJava; if (hJava->dwType != APXHANDLE_TYPE_JVM) return 0; lpJava = APXHANDLE_DATA(hJava); dwOrgOptions = lpJava->dwOptions; lpJava->dwOptions = dwOptions; return dwOrgOptions; } 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; } DWORD apxGetVmExitCode(void) { return vmExitCode; } void apxSetVmExitCode(DWORD exitCode) { vmExitCode = exitCode; return; } void apxJavaDumpAllStacks(APXHANDLE hJava) { BOOL bAttached; LPAPXJAVAVM lpJava; JNIEnv *lpEnv = NULL; if (DYNLOAD_FPTR(JVM_DumpAllStacks) == NULL || hJava == NULL || hJava->dwType != APXHANDLE_TYPE_JVM) return; lpJava = APXHANDLE_DATA(hJava); if (__apxJvmAttachEnv(lpJava, &lpEnv, &bAttached)) { DYNLOAD_FPTR(JVM_DumpAllStacks)(lpEnv, NULL); if (bAttached) (*(lpJava->lpJvm))->DetachCurrentThread(lpJava->lpJvm); } } commons-daemon-1.1.0-native-src/windows/src/mclib.h 0100664 0001750 0001750 00000002025 10533241454 022527 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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_ */ commons-daemon-1.1.0-native-src/windows/src/console.c 0100664 0001750 0001750 00000010207 10533241454 023077 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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; } commons-daemon-1.1.0-native-src/windows/src/service.c 0100664 0001750 0001750 00000065106 13200071625 023100 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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; \ } 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 WCHAR __invalidPathChars[] = L"<>:\"/\\:|?*"; static BOOL __apxIsValidServiceName(LPCWSTR szServiceName) { WCHAR ch; int i = 0; while ((ch = szServiceName[i++])) { int j = 0; while (__invalidPathChars[j]) { if (ch < 30 || ch == __invalidPathChars[j++]) { apxDisplayError(FALSE, NULL, 0, "Service '%S' contains invalid character '%C'", szServiceName, ch); return FALSE; } } } if (i > 256) { apxDisplayError(FALSE, NULL, 0, "Service name too long %S", szServiceName); return FALSE; } 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))) { if (GetLastError() != ERROR_ACCESS_DENIED) 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; } lstrlcpyW(lpService->stServiceEntry.szServiceName, SIZ_RESLEN, szServiceName); if (!apxGetServiceDescriptionW(szServiceName, lpService->stServiceEntry.szServiceDescription, SIZ_DESLEN)) { apxLogWrite(APXLOG_MARK_WARN "Failed to obtain service description"); lpService->stServiceEntry.szServiceDescription[0] = L'\0'; } if (!apxGetServiceUserW(szServiceName, lpService->stServiceEntry.szObjectName, SIZ_RESLEN)) { apxLogWrite(APXLOG_MARK_WARN "Failed to obtain service user name"); lpService->stServiceEntry.szObjectName[0] = L'\0'; } if (!QueryServiceConfigW(lpService->hService, NULL, 0, &dwNeeded)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // This is expected. The call is expected to fail with the required // buffer size set in dwNeeded. // Clear the last error to prevent it being logged if a genuine // error occurs SetLastError(ERROR_SUCCESS); } else { apxLogWrite(APXLOG_MARK_SYSERR); } } 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; DWORD dwServiceType = SERVICE_NO_CHANGE; 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 (szUsername || szPassword) dwServiceType = SERVICE_WIN32_OWN_PROCESS; if (!ChangeServiceConfigW(lpService->hService, dwServiceType, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, szImagePath, NULL, NULL, NULL, szUsername, szPassword, szDisplayName)) { apxLogWrite(APXLOG_MARK_SYSERR); return FALSE; } if (szDescription) { SERVICE_DESCRIPTIONW desc; desc.lpDescription = (LPWSTR)szDescription; return ChangeServiceConfig2(lpService->hService, SERVICE_CONFIG_DESCRIPTION, &desc); } 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); } static BOOL __apxStopDependentServices(LPAPXSERVICE lpService) { DWORD i; DWORD dwBytesNeeded; DWORD dwCount; LPENUM_SERVICE_STATUSW lpDependencies = NULL; ENUM_SERVICE_STATUS ess; SC_HANDLE hDepService; SERVICE_STATUS_PROCESS ssp; DWORD dwStartTime = GetTickCount(); /* Use the 30-second time-out */ DWORD dwTimeout = 30000; /* Pass a zero-length buffer to get the required buffer size. */ if (EnumDependentServicesW(lpService->hService, SERVICE_ACTIVE, lpDependencies, 0, &dwBytesNeeded, &dwCount)) { /* If the Enum call succeeds, then there are no dependent * services, so do nothing. */ return TRUE; } else { if (GetLastError() != ERROR_MORE_DATA) return FALSE; // Unexpected error /* Allocate a buffer for the dependencies. */ lpDependencies = (LPENUM_SERVICE_STATUS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBytesNeeded); if (!lpDependencies) return FALSE; __try { /* Enumerate the dependencies. */ if (!EnumDependentServicesW(lpService->hService, SERVICE_ACTIVE, lpDependencies, dwBytesNeeded, &dwBytesNeeded, &dwCount)) return FALSE; for (i = 0; i < dwCount; i++) { ess = *(lpDependencies + i); /* Open the service. */ hDepService = OpenServiceW(lpService->hManager, ess.lpServiceName, SERVICE_STOP | SERVICE_QUERY_STATUS); if (!hDepService) continue; if (lstrcmpiW(ess.lpServiceName, L"Tcpip") == 0 || lstrcmpiW(ess.lpServiceName, L"Afd") == 0) continue; __try { /* Send a stop code. */ if (!ControlService(hDepService, SERVICE_CONTROL_STOP, (LPSERVICE_STATUS) &ssp)) return FALSE; /* Wait for the service to stop. */ while (ssp.dwCurrentState != SERVICE_STOPPED) { Sleep(ssp.dwWaitHint); if (!QueryServiceStatusEx(hDepService, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp, sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded)) return FALSE; if (ssp.dwCurrentState == SERVICE_STOPPED) break; if (GetTickCount() - dwStartTime > dwTimeout) return FALSE; } } __finally { /* Always release the service handle. */ CloseServiceHandle(hDepService); } } } __finally { /* Always free the enumeration buffer. */ HeapFree(GetProcessHeap(), 0, lpDependencies); } } return TRUE; } 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, sleepMillis; BOOL bStatus; if (hService->dwType != APXHANDLE_TYPE_SERVICE) return FALSE; lpService = APXHANDLE_DATA(hService); /* Manager mode cannot handle services */ if (lpService->bManagerMode) { apxLogWrite(APXLOG_MARK_ERROR "apxServiceControl(): Manager mode cannot handle services, returning FALSE"); return FALSE; } /* Check if the ServiceOpen has been called */ if (IS_INVALID_HANDLE(lpService->hService)) { apxLogWrite(APXLOG_MARK_ERROR "apxServiceControl(): Service is not open, returning FALSE"); 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) { apxLogWrite(APXLOG_MARK_ERROR "apxServiceControl(): !dwPending(%d) && !dwState(%d); returning FALSE", dwPending, dwState); return FALSE; } /* Now lets control */ if (!QueryServiceStatus(lpService->hService, &stStatus)) { apxLogWrite(APXLOG_MARK_ERROR "apxServiceControl(): QueryServiceStatus failure, returning FALSE"); 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 = TRUE; if (dwControl == SERVICE_CONTROL_STOP) { /* First stop dependent services */ bStatus = __apxStopDependentServices(lpService); } if (bStatus) 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 */ sleepMillis = 1000; apxLogWrite(APXLOG_MARK_DEBUG "apxServiceControl(): Sleeping %d milliseconds", sleepMillis); Sleep(sleepMillis); if (QueryServiceStatus(lpService->hService, &stStatus)) { apxLogWrite(APXLOG_MARK_DEBUG "apxServiceControl(): QueryServiceStatus OK"); if (fnControlCallback) { apxLogWrite(APXLOG_MARK_DEBUG "apxServiceControl(): Calling fnControlCallback()"); (*fnControlCallback)(lpCbData, uMsg, (WPARAM)4, (LPARAM)&stStatus); apxLogWrite(APXLOG_MARK_DEBUG "apxServiceControl(): Returned from fnControlCallback()"); } if (stStatus.dwCurrentState == dwState) { return TRUE; } else { apxLogWrite(APXLOG_MARK_ERROR "apxServiceControl(): dwState(%d) != dwCurrentState(%d); " "dwWin32ExitCode = %d, dwWaitHint = %d, dwServiceSpecificExitCode = %d", dwState, stStatus.dwCurrentState, stStatus.dwWin32ExitCode, stStatus.dwWaitHint, stStatus.dwServiceSpecificExitCode); } } else { apxLogWrite(APXLOG_MARK_ERROR "apxServiceControl(): QueryServiceStatus failure"); } apxLogWrite(APXLOG_MARK_ERROR "apxServiceControl(): returning FALSE"); 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)); if (lpDependencies) lpDependencies = apxMultiSzCombine(NULL, lpDependencies, L"Tcpip\0Afd\0", NULL); else lpDependencies = L"Tcpip\0Afd\0"; 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); return FALSE; } else { lstrlcpyW(lpService->stServiceEntry.szServiceName, SIZ_RESLEN, 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); 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 again 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) { DWORD dwNeed; QueryServiceStatus(hSrv, &(stEntry.stServiceStatus)); QueryServiceStatusEx(hSrv, SC_STATUS_PROCESS_INFO, (LPBYTE)(&(stEntry.stStatusProcess)), sizeof(SERVICE_STATUS_PROCESS), &dwNeed); /* finally 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; } commons-daemon-1.1.0-native-src/windows/src/handles.c 0100664 0001750 0001750 00000047322 13177100417 023063 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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); /* 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 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; } 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; } commons-daemon-1.1.0-native-src/windows/src/utils.c 0100664 0001750 0001750 00000042535 13177100417 022606 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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" 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)) { apxLogWrite(APXLOG_MARK_SYSERR); apxFree(wsRet); 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)) { apxLogWrite(APXLOG_MARK_SYSERR); apxFree(szRet); return NULL; } return szRet; } BOOL apxAddToPathW(APXHANDLE hPool, LPCWSTR szAdd) { LPWSTR wsAdd; DWORD rc; DWORD al; rc = GetEnvironmentVariableW(L"PATH", NULL, 0); if (rc == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) return FALSE; al = lstrlenW(szAdd) + 6; if (!(wsAdd = apxPoolAlloc(hPool, (al + rc + 1) * sizeof(WCHAR)))) return FALSE; lstrcpyW(wsAdd, L"PATH="); lstrcatW(wsAdd, szAdd); lstrcatW(wsAdd, L";"); if (!GetEnvironmentVariableW(L"PATH", wsAdd + al, rc - al)) { apxLogWrite(APXLOG_MARK_SYSERR); apxFree(wsAdd); return FALSE; } SetEnvironmentVariableW(L"PATH", wsAdd + 5); _wputenv(wsAdd); apxFree(wsAdd); return TRUE; } 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 WideToANSI(LPCWSTR ws) { LPSTR s; int cch = WideCharToMultiByte(CP_ACP, 0, ws, -1, NULL, 0, NULL, NULL); s = (LPSTR)apxAlloc(cch); if (!WideCharToMultiByte(CP_ACP, 0, ws, -1, s, cch, NULL, NULL)) { apxFree(s); return NULL; } return s; } LPWSTR ANSIToWide(LPCSTR cs) { LPWSTR s; int cch = MultiByteToWideChar(CP_ACP, 0, cs, -1, NULL, 0); s = (LPWSTR)apxAlloc(cch * sizeof(WCHAR)); if (!MultiByteToWideChar(CP_ACP, 0, cs, -1, s, cch)) { apxFree(s); return NULL; } return s; } 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; } LPSTR MzWideToANSI(LPCWSTR ws) { LPSTR str; LPSTR s; LPCWSTR p = ws; int cch = 0; for ( ; p && *p; p++) { int len = WideCharToMultiByte(CP_ACP, 0, p, -1, NULL, 0, NULL, NULL); if (len > 0) cch += len; while (*p) p++; } cch ++; str = s = (LPSTR)apxAlloc(cch + 1); p = ws; for ( ; p && *p; p++) { int len = WideCharToMultiByte(CP_ACP, 0, p, -1, s, cch, NULL, NULL); if (len > 0) { s = s + len; cch -= len; } while (*p) p++; } /* double terminate */ *s = '\0'; return str; } 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 terminated 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)); 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)) LPTSTR apxStrCharRemove(LPTSTR szString, TCHAR chSkip) { LPTSTR p = szString; LPTSTR q = szString; if (IS_EMPTY_STRING(szString)) return 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; if (IS_EMPTY_STRING(szString)) return c; 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; if (IS_EMPTY_STRING(szString)) return c; 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; if (IS_EMPTY_STRING(szString)) return; 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; if (IS_EMPTY_STRING(szString)) return; 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 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); } 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; } 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)); while (c > 0) { if (*p) *b++ = *p; else { *b++ = L'\r'; *b++ = L'\n'; c--; } p++; } 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; } 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); } } commons-daemon-1.1.0-native-src/windows/src/registry.c 0100664 0001750 0001750 00000076352 13177034332 023324 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 * The code below assumes the JRE and JDK arrays are the same length */ static LPCWSTR JRE_REGKEYS[] = { L"SOFTWARE\\JavaSoft\\JRE\\", /* Oracle Java 8 and earlier */ L"SOFTWARE\\JavaSoft\\Java Runtime Environment\\", /* Oracle Java 9 (and hopefully later) */ L"SOFTWARE\\IBM\\Java2 Runtime Environment\\", /* IBM */ NULL }; static LPCWSTR JDK_REGKEYS[] = { L"SOFTWARE\\JavaSoft\\JDK\\", /* Oracle Java 8 and ealier */ L"SOFTWARE\\JavaSoft\\Java Development Kit\\", /* Oracle Java 9 (and hopefully later) */ L"SOFTWARE\\IBM\\Java2 Development Kit\\", /* IBM */ NULL }; static LPCWSTR JAVA_CURRENT = L"CurrentVersion"; static LPCWSTR JAVA_RUNTIME = L"RuntimeLib"; static LPCWSTR JAVA_HOME = L"JAVA_HOME"; static LPCWSTR JAVAHOME = L"JavaHome"; static LPCWSTR CONTROL_REGKEY = L"SYSTEM\\CurrentControlSet\\Control"; static LPCWSTR REGTIMEOUT = L"WaitToKillServiceTimeout"; #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) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } if (szRoot && lstrlenW(szRoot) > SIZ_RESMAX) { SetLastError(ERROR_INVALID_PARAMETER); 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; } 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; } 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 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) + 1) * 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; } LONG apxDeleteRegistryRecursive(HKEY hKeyRoot, LPCWSTR szSubKey) { LONG rc = ERROR_SUCCESS; DWORD dwSize = 0; WCHAR szName[SIZ_BUFLEN]; HKEY hKey = NULL; if (ERROR_SUCCESS == RegDeleteKeyW(hKeyRoot, szSubKey)) { return ERROR_SUCCESS; } rc = RegOpenKeyExW(hKeyRoot, szSubKey, 0, KEY_ENUMERATE_SUB_KEYS | DELETE, &hKey); if (rc != ERROR_SUCCESS) { if (rc == ERROR_FILE_NOT_FOUND) { return ERROR_SUCCESS; } else { return rc; } } while (rc == ERROR_SUCCESS) { dwSize = SIZ_BUFLEN; rc = RegEnumKeyExW(hKey, 0, szName, &dwSize, NULL, NULL, NULL, NULL ); if (rc == ERROR_NO_MORE_ITEMS) { rc = RegDeleteKeyW(hKeyRoot, szSubKey); break; } else { rc = apxDeleteRegistryRecursive(hKey, szName); if (rc != ERROR_SUCCESS) { break; // abort when we start failing } } } RegCloseKey(hKey); return rc; } BOOL apxDeleteRegistryW(LPCWSTR szRoot, LPCWSTR szKeyName, REGSAM samDesired, BOOL bDeleteEmptyRoot) { WCHAR buff[SIZ_BUFLEN]; LONG rc = ERROR_SUCCESS; HKEY hKey = NULL; BOOL rv = TRUE; HKEY hives[] = {HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, NULL}, *hive = NULL; if (!szKeyName || lstrlenW(szKeyName) > SIZ_RESMAX) return FALSE; if (szRoot && lstrlenW(szRoot) > SIZ_RESMAX) return FALSE; if (szRoot) lstrcpyW(buff, szRoot); else lstrcpyW(buff, REGAPACHE_ROOT); lstrcatW(buff, REGSEPARATOR); for (hive = &hives[0]; *hive; hive++) { HKEY hkeySoftware = NULL; rc = RegOpenKeyExW(*hive, REGSOFTWARE_ROOT, 0, KEY_READ | samDesired, &hkeySoftware); if (rc != ERROR_SUCCESS) { rv = FALSE; } else { rc = RegOpenKeyExW(hkeySoftware, buff, 0, samDesired | KEY_ENUMERATE_SUB_KEYS | DELETE, &hKey); if (rc == ERROR_SUCCESS) { rc = apxDeleteRegistryRecursive(hKey, szKeyName); RegCloseKey(hKey); hKey = NULL; rv |= (rc == ERROR_SUCCESS); } if (bDeleteEmptyRoot) { // will fail if there are subkeys, just like we want RegDeleteKeyW(hkeySoftware, buff); } RegCloseKey(hkeySoftware); } } return rv; } LPWSTR apxGetJavaSoftHome(APXHANDLE hPool, BOOL bPreferJre) { LPWSTR wsJhome, off; DWORD err, dwLen, dwRegKey = 0; 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 while (JRE_REGKEYS[dwRegKey]) { lstrcpyW(wsKey, JAVA_CURRENT); if (bPreferJre) lstrcpyW(wsBuf, JRE_REGKEYS[dwRegKey]); else lstrcpyW(wsBuf, JDK_REGKEYS[dwRegKey]); dwRegKey = dwRegKey++; dwLen = lstrlenW(wsBuf); off = &wsBuf[dwLen]; dwLen = SIZ_RESMAX; if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) { continue; } if ((err = RegQueryValueExW(hKey, JAVA_CURRENT, NULL, NULL, (LPBYTE)off, &dwLen)) != ERROR_SUCCESS) { RegCloseKey(hKey); continue; } RegCloseKey(hKey); if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) { continue; } wsJhome = __apxGetRegistrySzW(hPool, hKey, JAVAHOME); if (wsJhome) SetEnvironmentVariableW(JAVA_HOME, wsJhome); RegCloseKey(hKey); return wsJhome; } return NULL; } LPWSTR apxGetJavaSoftRuntimeLib(APXHANDLE hPool) { LPWSTR wsRtlib, off; DWORD err, dwLen = SIZ_RESLEN, dwRegKey = 0; HKEY hKey; WCHAR wsBuf[SIZ_BUFLEN]; while(JRE_REGKEYS[dwRegKey]) { lstrcpyW(wsBuf, JRE_REGKEYS[dwRegKey]); dwRegKey = dwRegKey++; dwLen = lstrlenW(wsBuf); off = &wsBuf[dwLen]; dwLen = SIZ_RESLEN; if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) { continue; } if ((err = RegQueryValueExW(hKey, JAVA_CURRENT, NULL, NULL, (LPBYTE)off, &dwLen)) != ERROR_SUCCESS) { RegCloseKey(hKey); continue; } RegCloseKey(hKey); if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) { continue; } wsRtlib = __apxGetRegistrySzW(hPool, hKey, JAVA_RUNTIME); RegCloseKey(hKey); return wsRtlib; } return NULL; } /* 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; } 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; } DWORD apxGetMaxServiceTimeout(APXHANDLE hPool) { DWORD maxTimeout = 20000; LPWSTR wsMaxTimeout; DWORD err; HKEY hKey; WCHAR wsBuf[SIZ_BUFLEN]; lstrcpyW(wsBuf, CONTROL_REGKEY); if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) { return maxTimeout; } wsMaxTimeout = __apxGetRegistrySzW(hPool, hKey, REGTIMEOUT); RegCloseKey(hKey); if (wsMaxTimeout[0]) { maxTimeout = (DWORD)apxAtoulW(wsMaxTimeout); } apxFree(wsMaxTimeout); return maxTimeout; } commons-daemon-1.1.0-native-src/windows/src/mclib.c 0100664 0001750 0001750 00000025644 13177061540 022541 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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; } /* * Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters * will be copied. Always NUL terminates (unless siz <= strlen(dst)). * Returns strlen(src) + MIN(siz, strlen(initial dst)). * If retval >= siz, truncation occurred. */ LPSTR lstrlcatA(LPSTR dst, int siz, LPCSTR src) { LPSTR d = dst; LPCSTR s = src; int n = siz; int dlen; /* Find the end of dst and adjust bytes left but don't go past end */ while (n-- != 0 && *d != '\0') d++; dlen = (int)(d - dst); n = siz - dlen; if (n == 0) return NULL; while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; } *d = '\0'; return dst; } LPWSTR lstrlcatW(LPWSTR dst, int siz, LPCWSTR src) { LPWSTR d = dst; LPCWSTR s = src; int n = siz; int dlen; /* Find the end of dst and adjust bytes left but don't go past end */ while (n-- != 0 && *d != '\0') d++; dlen = (int)(d - dst); n = siz - dlen; if (n == 0) return NULL; while (*s != L'\0') { if (n != 1) { *d++ = *s; n--; } s++; } *d = L'\0'; return dst; } LPSTR lstrlcpyA(LPSTR dst, int siz, LPCSTR src) { LPSTR d = dst; LPCSTR s = src; int n = siz; /* Copy as many bytes as will fit */ if (n != 0) { while (--n != 0) { if ((*d++ = *s++) == '\0') break; } } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return d; } LPWSTR lstrlcpyW(LPWSTR dst, int siz, LPCWSTR src) { LPWSTR d = dst; LPCWSTR s = src; int n = siz; /* Copy as many bytes as will fit */ if (n != 0) { while (--n != 0) { if ((*d++ = *s++) == L'\0') break; } } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = L'\0'; /* NUL-terminate dst */ while (*s++) ; } return d; } LPWSTR lstrlocaseW(LPWSTR str) { LPWSTR p = str; while (p && *p != 0) { *p = towlower(*p); p++; } return str; } commons-daemon-1.1.0-native-src/windows/src/private.h 0100664 0001750 0001750 00000025325 13177100417 023123 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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) /* 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 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_ */ commons-daemon-1.1.0-native-src/windows/src/cmdline.c 0100664 0001750 0001750 00000026571 13177024616 023071 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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) #define X86_SUFFIX L".X86" #define X64_SUFFIX L".X64" /* 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, LPCWSTR *lpszAltcmds) { LPAPXCMDLINE lpCmdline = NULL; DWORD l, i, s = 1; LPWSTR p; DWORD match; WCHAR mh[SIZ_HUGLEN]; if (_st_sys_argc < 1) return NULL; if (!(lpCmdline = (LPAPXCMDLINE)apxPoolCalloc(hPool, sizeof(APXCMDLINE)))) return NULL; lpCmdline->hPool = hPool; lpCmdline->lpOptions = lpOptions; if (GetModuleFileNameW(GetModuleHandle(NULL), mh, SIZ_HUGLEN)) { GetLongPathNameW(mh, mh, SIZ_HUGLEN); lpCmdline->szExePath = apxPoolStrdupW(hPool, mh); lpCmdline->szArgv0 = apxPoolStrdupW(hPool, mh); if (lpCmdline->szExePath == NULL || lpCmdline->szArgv0 == NULL) return NULL; if ((p = wcsrchr(lpCmdline->szExePath, L'\\'))) *p++ = L'\0'; else return NULL; } else return NULL; lpCmdline->szExecutable = p; p = wcsrchr(lpCmdline->szExecutable, L'.'); if (p && lstrcmpiW(p, EXE_SUFFIX) == 0) *p = L'\0'; if ((p = wcsrchr(lpCmdline->szExecutable, L'.'))) { if (lstrcmpiW(p, X86_SUFFIX) == 0) { *p = L'\0'; } else if (lstrcmpiW(p, X64_SUFFIX) == 0) { *p = L'\0'; } } if (_st_sys_argc > 1 && lstrlenW(_st_sys_argvw[1]) > 2) { LPWSTR cp = _st_sys_argvw[1]; LPWSTR cn = _st_sys_argc > 2 ? _st_sys_argvw[2] : NULL; LPWSTR ca = cp; i = 0; if (ca[0] == L'/' && ca[1] == L'/') { ca += 2; if ((cn = wcschr(ca, L'/'))) { *cn++ = L'\0'; while (*cn == L'/') cn++; if (*cn == L'\0') cn = NULL; } if (cn == NULL) cn = lpCmdline->szExecutable; while (lpszCommands[i]) { if (lstrcmpW(lpszCommands[i++], ca) == 0) { lpCmdline->dwCmdIndex = i; break; } } if (lpCmdline->dwCmdIndex) { lpCmdline->szApplication = cn; s = 2; } else { apxLogWrite(APXLOG_MARK_ERROR "Unrecognized cmd option %S", cp); return NULL; } } else { while (lpszAltcmds[i]) { if (lstrcmpW(lpszAltcmds[i++], ca) == 0) { lpCmdline->dwCmdIndex = i; break; } } if (lpCmdline->dwCmdIndex) { s = 2; if (cn && iswalnum(*cn)) { s++; lpCmdline->szApplication = cn; } else lpCmdline->szApplication = lpCmdline->szExecutable; } else { apxLogWrite(APXLOG_MARK_ERROR "Unrecognized cmd option %S", cp); return NULL; } } } else { lpCmdline->szApplication = lpCmdline->szExecutable; lpCmdline->dwCmdIndex = 1; return lpCmdline; } for (i = s; i < (DWORD)_st_sys_argc; i++) { LPWSTR e = NULL; LPWSTR a = _st_sys_argvw[i]; BOOL add = FALSE; if (a[0] == L'+' && a[1] == L'+') add = TRUE; else if (a[0] != L'-' || a[1] != L'-') break; p = a + 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, a + 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 (add) { if (!(lpOptions[l].dwType & APXCMDOPT_FOUND)) { /* Only set add flag in case there was no --option */ lpOptions[l].dwType |= APXCMDOPT_ADD; } } else if (lpOptions[l].dwType & APXCMDOPT_ADD) { /* We have ++option --option ... * Discard earlier values and go over. */ lpOptions[l].dwType &= ~APXCMDOPT_ADD; lpOptions[l].dwValue = 0; lpOptions[l].szValue = 0; } 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; match = l + 1; break; } } if (match == 0) { /* --unknown option * */ apxLogWrite(APXLOG_MARK_ERROR "Unrecognized program option %S", _st_sys_argvw[i]); return NULL; } } 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 variables 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]; lstrlcpyW(szEnv, 64, L"PR_"); lstrlcatW(szEnv, 64, lpCmdline->lpOptions[i].szName); l = GetEnvironmentVariableW(szEnv, szVar, SIZ_HUGMAX); if (l == 0 || l >= SIZ_HUGMAX) { if (l == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) { apxLogWrite(APXLOG_MARK_ERROR "Error geting environment variable %S", szEnv); return; } ++i; continue; } if (lpCmdline->lpOptions[i].dwType & APXCMDOPT_STR) { lpCmdline->lpOptions[i].szValue = apxPoolStrdupW(lpCmdline->hPool, szVar); lpCmdline->lpOptions[i].dwType |= APXCMDOPT_FOUND; } else if (lpCmdline->lpOptions[i].dwType & APXCMDOPT_INT) { lpCmdline->lpOptions[i].dwValue = (DWORD)apxAtoulW(szVar); lpCmdline->lpOptions[i].dwType |= APXCMDOPT_FOUND; } else if (lpCmdline->lpOptions[i].dwType & APXCMDOPT_MSZ) { LPWSTR pp; BOOL insquote = FALSE, indquote = FALSE; DWORD sp = 0; lpCmdline->lpOptions[i].dwValue = (lstrlenW(szVar) + 2) * sizeof(WCHAR); lpCmdline->lpOptions[i].szValue = apxPoolCalloc(lpCmdline->hPool, lpCmdline->lpOptions[i].dwValue); 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; } } commons-daemon-1.1.0-native-src/windows/src/gui.c 0100664 0001750 0001750 00000072060 13200071625 022221 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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])) /* 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; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &_st_sys_gui.nWhellScroll, 0); 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; if (hwndParent == NULL) hwndParent = GetDesktopWindow(); /* 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"), apxLoadResourceW(IDS_APPLICATION, 0)); ShellAbout(hWnd, szApplication, apxLoadResourceW(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, apxLoadResourceW(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); } /* Browse for folder dialog. */ 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; } 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); 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; } commons-daemon-1.1.0-native-src/windows/src/rprocess.c 0100664 0001750 0001750 00000064610 13177071102 023302 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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; /* store worker's exit code as VM exit code for later use */ GetExitCodeProcess(lpProc->stProcInfo.hProcess, &dwExitCode); apxLogWrite(APXLOG_MARK_DEBUG "Child process exit code %d", dwExitCode); apxSetVmExitCode(dwExitCode); } 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; apxLogWrite(APXLOG_MARK_DEBUG "Commons Daemon procrun __apxProcCreateChildPipes()"); if (!CreatePipe(&(lpProc->hChildStdInp), &(lpProc->hChildInpWr), lpProc->lpSA, 0)) { apxLogWrite(APXLOG_MARK_SYSERR); goto cleanup; } if (!SetHandleInformation(lpProc->hChildInpWr, HANDLE_FLAG_INHERIT, 0)) { apxLogWrite(APXLOG_MARK_SYSERR); goto cleanup; } if (!CreatePipe(&(lpProc->hChildOutRd), &(lpProc->hChildStdOut), lpProc->lpSA, 0)) { apxLogWrite(APXLOG_MARK_SYSERR); goto cleanup; } if (!SetHandleInformation(lpProc->hChildOutRd, HANDLE_FLAG_INHERIT, 0)) { apxLogWrite(APXLOG_MARK_SYSERR); goto cleanup; } if (!CreatePipe(&(lpProc->hChildErrRd), &(lpProc->hChildStdErr), lpProc->lpSA, 0)) { apxLogWrite(APXLOG_MARK_SYSERR); goto cleanup; } if (!SetHandleInformation(lpProc->hChildErrRd, HANDLE_FLAG_INHERIT, 0)) { apxLogWrite(APXLOG_MARK_SYSERR); 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; } APXHANDLE apxCreateProcessW(APXHANDLE hPool, DWORD dwOptions, LPAPXFNCALLBACK fnCallback, LPCWSTR szUsername, LPCWSTR szPassword, BOOL bLogonAsService) { APXHANDLE hProcess; LPAPXPROCESS lpProc; HANDLE hUserToken = NULL; if (szUsername) { HANDLE hUser; if (!LogonUserW(szUsername, NULL, szPassword, bLogonAsService ? LOGON32_LOGON_SERVICE : LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &hUser)) { /* Logon Failed */ apxLogWrite(APXLOG_MARK_SYSERR); return NULL; } if (!DuplicateTokenEx(hUser, TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY, NULL, SecurityImpersonation, TokenPrimary, &hUserToken)) { CloseHandle(hUser); /* Failed to duplicate the user token */ apxLogWrite(APXLOG_MARK_SYSERR); return NULL; } if (!ImpersonateLoggedOnUser(hUserToken)) { CloseHandle(hUser); CloseHandle(hUserToken); /* failed to impersonate the logged user */ apxLogWrite(APXLOG_MARK_SYSERR); 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; apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon apxProcessExecute()"); 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); apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon AplZeroMemory()"); 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) { apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon FreeEnvironmentStringsW()"); FreeEnvironmentStringsW(lpProc->lpEnvironment); } apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon GetEnvironmentStringsW()"); lpProc->lpEnvironment = GetEnvironmentStringsW(); if (!IS_INVALID_HANDLE(lpProc->hUserToken)) { si.lpDesktop = _desktop_name; apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon CreateProcessAsUserW()"); 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); apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon CreateProcessW()"); 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); apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon CreateThread()"); lpProc->hWorkerThreads[0] = CreateThread(NULL, 0, __apxProcStdoutThread, hProcess, 0, &id); apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon CreateThread()"); lpProc->hWorkerThreads[1] = CreateThread(NULL, 0, __apxProcStderrThread, hProcess, 0, &id); apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon ResumeThread()"); ResumeThread(lpProc->stProcInfo.hThread); apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon CreateThread()"); lpProc->hWorkerThreads[2] = CreateThread(NULL, 0, __apxProcWorkerThread, hProcess, 0, &id); SAFE_CLOSE_HANDLE(lpProc->stProcInfo.hThread); /* Close child handles first */ apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon apxProcessExecute() returning TRUE"); return TRUE; cleanup: /* Close parent side of the pipes */ SAFE_CLOSE_HANDLE(lpProc->hChildInpWr); SAFE_CLOSE_HANDLE(lpProc->hChildOutRd); SAFE_CLOSE_HANDLE(lpProc->hChildErrRd); apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon apxProcessExecute() returning FALSE"); return FALSE; } 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 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 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 = apxPoolStrdupW(hProcess->hPool, szPath); return lpProc->szWorkingPath != NULL; } 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); } DWORD apxProcessGetPid(APXHANDLE hProcess) { LPAPXPROCESS lpProc; if (hProcess->dwType != APXHANDLE_TYPE_PROCESS) return 0; lpProc = APXHANDLE_DATA(hProcess); return lpProc->stProcInfo.dwProcessId; } static LPWSTR __apxStrQuote(LPWSTR lpDest, LPCWSTR szSrc) { LPWSTR p; BOOL space = FALSE, quote = FALSE; /* Find if string has embeded spaces, add quotes only if no quotes found */ for (p = (LPWSTR)szSrc; *p; p++) { if (*p == L' ' || *p == '\t') { space = TRUE; } else if (*p == L'"') { quote = TRUE; } } p = lpDest; if (space && !quote) *p++ = L'"'; while (*szSrc) { *p++ = *szSrc++; } if (space && !quote) *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 < dwArgc; i++) { int q = 0; l += (lstrlenW(lpArgs[i]) + 3); 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; } commons-daemon-1.1.0-native-src/windows/src/log.c 0100664 0001750 0001750 00000036341 13017110374 022221 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 <stdio.h> #define LINE_SEP "\r\n" #define LOGF_EXT L".%04d-%02d-%02d.log" #define LOGF_EXR L".%04d-%02d-%02d.%02d%02d%02d.log" static LPCSTR _log_level[] = { "[debug] ", "[info] ", "[warn] ", "[error] ", NULL }; typedef struct apx_logfile_st { HANDLE hFile; DWORD dwLogLevel; DWORD dwRotate; SYSTEMTIME sysTime; WCHAR szPath[SIZ_PATHLEN]; WCHAR szPrefix[MAX_PATH]; WCHAR szFile[MAX_PATH]; } apx_logfile_st; /* Per-application master log file */ static apx_logfile_st *_st_sys_loghandle = NULL; static CRITICAL_SECTION _st_sys_loglock; static CRITICAL_SECTION *_pt_sys_loglock = NULL; static apx_logfile_st _st_sys_errhandle = { NULL, APXLOG_LEVEL_WARN, FALSE}; static void logRotate(apx_logfile_st *lf, LPSYSTEMTIME t) { WCHAR sName[SIZ_PATHLEN]; ULARGE_INTEGER cft; ULARGE_INTEGER lft; HANDLE h; if (lf->dwRotate == 0) return; SystemTimeToFileTime(&lf->sysTime, (LPFILETIME)&lft); SystemTimeToFileTime(t, (LPFILETIME)&cft); if (cft.QuadPart < (lft.QuadPart + lf->dwRotate * 10000000ULL)) return; /* Rotate time */ lf->sysTime = *t; if (lf->dwRotate < 86400) wsprintfW(sName, L"\\%s" LOGF_EXR, lf->szPrefix, lf->sysTime.wYear, lf->sysTime.wMonth, lf->sysTime.wDay, lf->sysTime.wHour, lf->sysTime.wMinute, lf->sysTime.wSecond); else wsprintfW(sName, L"\\%s" LOGF_EXT, lf->szPrefix, lf->sysTime.wYear, lf->sysTime.wMonth, lf->sysTime.wDay); lstrlcpyW(lf->szFile, MAX_PATH, lf->szPath); lstrlcatW(lf->szFile, MAX_PATH, sName); h = CreateFileW(lf->szFile, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (h == INVALID_HANDLE_VALUE) { /* TODO: Log something */ return; } /* Make sure we relock the correct file */ APX_LOGLOCK(h); APX_LOGUNLOCK(lf->hFile); /* Close original handle */ CloseHandle(lf->hFile); lf->hFile = h; } LPWSTR apxLogFile( APXHANDLE hPool, LPCWSTR szPath, LPCWSTR szPrefix, LPCWSTR szName, BOOL bTimeStamp, DWORD dwRotate) { LPWSTR sRet; WCHAR sPath[SIZ_PATHLEN]; WCHAR sName[SIZ_PATHLEN]; SYSTEMTIME sysTime; GetLocalTime(&sysTime); if (!szPath) { if (GetSystemDirectoryW(sPath, MAX_PATH) == 0) return INVALID_HANDLE_VALUE; lstrlcatW(sPath, MAX_PATH, L"\\LogFiles\\Apache"); } else { lstrlcpyW(sPath, MAX_PATH, szPath); } if (!szPrefix) szPrefix = L""; if (!szName) szName = L""; if (bTimeStamp) { if (dwRotate != 0 && dwRotate < 86400) wsprintfW(sName, L"\\%s%s" LOGF_EXR, szPrefix, szName, sysTime.wYear, sysTime.wMonth, sysTime.wDay, 0, 0, 0); else wsprintfW(sName, L"\\%s%s" LOGF_EXT, szPrefix, szName, sysTime.wYear, sysTime.wMonth, sysTime.wDay); } else { wsprintfW(sName, L"\\%s%s", szPrefix, szName); } sRet = apxPoolAlloc(hPool, (SIZ_PATHLEN) * sizeof(WCHAR)); /* Set default level to info */ CreateDirectoryW(sPath, NULL); lstrlcpyW(sRet, SIZ_PATHMAX, sPath); lstrlcatW(sRet, SIZ_PATHMAX, 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, DWORD dwRotate) { WCHAR sPath[SIZ_PATHLEN]; WCHAR sName[SIZ_PATHLEN]; SYSTEMTIME sysTime; apx_logfile_st *h; if (_pt_sys_loglock == NULL) { InitializeCriticalSection(&_st_sys_loglock); _pt_sys_loglock = &_st_sys_loglock; } GetLocalTime(&sysTime); if (!szPath) { if (GetSystemDirectoryW(sPath, MAX_PATH) == 0) return INVALID_HANDLE_VALUE; lstrlcatW(sPath, MAX_PATH, L"\\LogFiles"); if (!CreateDirectoryW(sPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) { if (!CreateDirectoryW(sPath, NULL)) return INVALID_HANDLE_VALUE; } lstrlcatW(sPath, MAX_PATH, L"\\Apache"); if (!CreateDirectoryW(sPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) { if (!CreateDirectoryW(sPath, NULL)) return INVALID_HANDLE_VALUE; } } else { lstrlcpyW(sPath, MAX_PATH, szPath); } if (!szPrefix) szPrefix = L"commons-daemon"; if (dwRotate != 0 && dwRotate < 86400) wsprintfW(sName, L"\\%s" LOGF_EXR, szPrefix, sysTime.wYear, sysTime.wMonth, sysTime.wDay, 0, 0, 0); else wsprintfW(sName, L"\\%s" LOGF_EXT, szPrefix, sysTime.wYear, sysTime.wMonth, sysTime.wDay); if (!(h = (apx_logfile_st *)apxPoolCalloc(hPool, sizeof(apx_logfile_st)))) return INVALID_HANDLE_VALUE; /* Set default level to info */ h->dwLogLevel = APXLOG_LEVEL_INFO; CreateDirectoryW(sPath, NULL); h->sysTime = sysTime; lstrlcpyW(h->szPath, MAX_PATH, sPath); lstrlcpyW(h->szFile, MAX_PATH, sPath); lstrlcatW(h->szFile, MAX_PATH, sName); lstrlcpyW(h->szPrefix, MAX_PATH, szPrefix); h->hFile = CreateFileW(h->szFile, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (h->hFile == INVALID_HANDLE_VALUE) { /* Make sure we write somewhere */ h = &_st_sys_errhandle; apxDisplayError(FALSE, NULL, 0, "Unable to create logger at '%S'\n", h->szFile); return (HANDLE)h; } else { h->dwRotate = dwRotate; } /* 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 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; } } 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[SIZ_PATHLEN]; DWORD wr; DWORD err; BOOL dolock = TRUE; apx_logfile_st *lf = (apx_logfile_st *)hFile; err = GetLastError(); /* save the last Error code */ if (IS_INVALID_HANDLE(lf)) lf = _st_sys_loghandle; if (IS_INVALID_HANDLE(lf)) { lf = &_st_sys_errhandle; lf->hFile = GetStdHandle(STD_ERROR_HANDLE); } if (lf == &_st_sys_errhandle) { /* Do not rotate if redirected to console */ dolock = FALSE; } if (dwLevel < lf->dwLogLevel) return 0; APX_LOGENTER(); if (f && (lf->dwLogLevel == APXLOG_LEVEL_DEBUG || dwLevel == APXLOG_LEVEL_ERROR)) { f = (szFile + lstrlenA(szFile) - 1); while(f != szFile && '\\' != *f && '/' != *f) f--; if(f != szFile) f++; } else f = NULL; szBp = buffer; if (!szFormat) { if (err == 0) { lstrcpyA(szBp, "Unknown error code"); if (dwLevel == APXLOG_LEVEL_ERROR) { szBp += 18; wsprintfA(szBp, " occured in (%s:%d) ", f, dwLine); } } else 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] = '\0'; if (len > 0 && buffer[len - 1] == '\r') buffer[--len] = '\0'; if (!IS_INVALID_HANDLE(lf->hFile)) { SYSTEMTIME t; /* Append operation */ SetFilePointer(lf->hFile, 0, &wr, FILE_END); GetLocalTime(&t); if (dolock) { APX_LOGLOCK(lf->hFile); logRotate(lf, &t); } 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); } WriteFile(lf->hFile, _log_level[dwLevel], lstrlenA(_log_level[dwLevel]), &wr, NULL); if (f && lf->dwLogLevel == APXLOG_LEVEL_DEBUG) { wsprintfA(sb, "(%10s:%-4d) ", f, dwLine); WriteFile(lf->hFile, sb, lstrlenA(sb), &wr, NULL); } /* add thread ID to log output */ wsprintfA(sb, "[%5d] ", GetCurrentThreadId()); WriteFile(lf->hFile, sb, lstrlenA(sb), &wr, NULL); if (len) WriteFile(lf->hFile, buffer, len, &wr, NULL); /* Terminate the line */ WriteFile(lf->hFile, LINE_SEP, sizeof(LINE_SEP) - 1, &wr, NULL); if (dwLevel) FlushFileBuffers(lf->hFile); if (dolock) { APX_LOGUNLOCK(lf->hFile); } } #ifdef _DEBUG_FULL { char tid[1024 + 16]; wsprintfA(tid, "[%04d] %s", GetCurrentThreadId(), buffer); OutputDebugStringA(tid); } #endif } APX_LOGLEAVE(); /* Restore the last Error code */ SetLastError(err); if (szFormat && err != 0 && dwLevel == APXLOG_LEVEL_ERROR) { /* Print the System error description */ apxLogWrite(hFile, dwLevel, bTimeStamp, szFile, dwLine, NULL); } 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[SIZ_HUGLEN]; CHAR sysbuf[SIZ_HUGLEN]; 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++; } else 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, SIZ_DESLEN, NULL); sysbuf[len] = '\0'; if (len > 0) { if (sysbuf[len - 1] == '\n') sysbuf[--len] = '\0'; if (len > 0 && sysbuf[len - 1] == '\r') sysbuf[--len] = '\0'; } } if (szFormat) { va_start(args, szFormat); wvsprintfA(buffer, szFormat, args); va_end(args); if (f && *f) { CHAR sb[SIZ_PATHLEN]; wsprintfA(sb, "%s (%d)", f, dwLine); lstrcatA(sysbuf, sb); } lstrlcatA(sysbuf, SIZ_HUGLEN, LINE_SEP); lstrlcatA(sysbuf, SIZ_HUGLEN, buffer); } len = lstrlenA(sysbuf); #ifdef _DEBUG_FULL OutputDebugStringA(sysbuf); #endif if (len > 0) { if (bDisplay) { nRet = MessageBoxA(NULL, sysbuf, "Application System Error", MB_ICONERROR | MB_OK | MB_SYSTEMMODAL); } else { fputs(sysbuf, stderr); if (!szFormat) fputs(LINE_SEP, stderr); fflush(stderr); } } /* Restore the last Error code */ SetLastError(err); return len; } commons-daemon-1.1.0-native-src/windows/README 0100664 0001750 0001750 00000003246 13177024616 021375 0 ustar 00mark mark 0000000 0000000 Configuring and Building Commons Daemon on Windows ================================================== Using Visual Studio, you can build the Commons Daemon. The Makefile make file has a bunch of documentation about its options, but a trivial build is simply; nmake CPU=X86 nmake CPU=X86 PREFIX=c:\desired\path\of\daemon install Needed Tools ============ Commons Daemon needs the Microsoft Visual C 6/SP5 to build the x86 binaries. This is because this compiler doesn't create MSVCRTnn.DLL dependencies which will be loaded inside running JVM if used. For building AMD64/EMT64 binaries use the Platform SDK for Windows Server 2003R2. Step by Step ============ 0. These were written for 64-bit XP. YMMV. 1. Install the pre-requisites: - Microsoft Visual C 6 - Microsoft Visual C 6 Service Pack 5 - Platform SDK for Windows Server 2003 R2 2. Open a new command prompt (to ensure the environment is clean) You'll need to do this for each different platform you want to build 3. Configure the Visual C environment variables Not necessary if the option to add them to the user's environment was selected on install %VC6_DIR%\Bin\VCVARS32.BAT (e.g. "c:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT") 4. Configure the Platform SDK environment (optional for X86?) - win32 <PlatformSdkDir>\SetEnv /SRV32 /RETAIL - x64 <PlatformSdkDir>\SetEnv /X64 /RETAIL - i64 <PlatformSdkDir>\SetEnv /SRV64 /RETAIL 5. On 64-bit platforms set the following environment variable set EXTRA_CFLAGS=/GS- 6. Build the binary - win32 nmake CPU=X86 - x64 nmake CPU=X64 commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.rc 0100664 0001750 0001750 00000031555 13200414307 025161 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "Commons Daemon 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_COMMONS BITMAP "../../resources/commons.bmp" CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "prunmgr.manifest" 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_COMMONS",IDC_STATIC,"Static",SS_BITMAP|0x00000040L,0,0,337,30 LTEXT " ",IDC_ABOUTAPP,2,150,270,12 LTEXT "Copyright (c) 2000-2017 The Apache Software Foundation.",IDC_STATIC,2,160,270,12 LTEXT "http://commons.apache.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 Commons Daemon 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, 243 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, 243 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, 243 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 "Pid file: ",IDC_STATIC,10,81,50,8 EDITTEXT IDC_PPLGPIDFILE,70,82,158,12,ES_AUTOHSCROLL LTEXT "Redirect Stdout: ",IDC_STATIC,10,105,80,8 EDITTEXT IDC_PPLGSTDOUT,10,117,218,12,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_PPLGBSTDOUT,232,116,18,14 LTEXT "Redirect Stderror: ",IDC_STATIC,10,135,80,8 EDITTEXT IDC_PPLGSTDERR,10,147,218,12,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_PPLGBSTDERR,232,146,18,14 END IDD_PROPPAGE_JVM DIALOGEX 0, 0, 260, 243 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 "Java 9 Options:",IDC_STATIC,10,140,66,8 EDITTEXT IDC_PPJOPTIONS9,10,152,240,40,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL LTEXT "Initial memory pool:",IDC_STATIC,10,197,80,8 EDITTEXT IDC_PPJMS,90,196,100,12,ES_AUTOHSCROLL | ES_NUMBER LTEXT "MB",IDC_STATIC,195,197,25,8 LTEXT "Maximum memory pool:",IDC_STATIC,10,213,80,8 EDITTEXT IDC_PPJMX,90,212,100,12,ES_AUTOHSCROLL | ES_NUMBER LTEXT "MB",IDC_STATIC,195,213,25,8 LTEXT "Thread stack size:",IDC_STATIC,10,229,80,8 EDITTEXT IDC_PPJSS,90,228,100,12,ES_AUTOHSCROLL | ES_NUMBER LTEXT "KB",IDC_STATIC,195,229,25,8 END IDD_PROPPAGE_START DIALOGEX 0, 0, 260, 243 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, 243 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.1.0" IDS_APPFULLNAME RSTR_PSM " Version " PRG_VERSION IDS_APPCOPYRIGHT "Copyright (c) 2000-2017 The Apache Software Foundation" IDS_APPDESCRIPTION "Apache Commons Daemon 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 1,1,0,0 PRODUCTVERSION 1,1,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", "Commons Daemon 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 (c) 2000-2017 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 commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.rc 0100664 0001750 0001750 00000003463 13127316537 025246 0 ustar 00mark mark 0000000 0000000 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 "Commons Daemon Service Runner" IDI_MAINICON ICON "../../resources/procrunw.ico" CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "prunsrv.manifest" 1 VERSIONINFO FILEVERSION 1,1,0,0 PRODUCTVERSION 1,1,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_PRUNSRV "\0" VALUE "FileVersion", PRG_VERSION VALUE "InternalName", RSTR_PRUNSRV "\0" VALUE "LegalCopyright", "Copyright (c) 2000-2017 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 commons-daemon-1.1.0-native-src/windows/resources/susers.bmp 0100664 0001750 0001750 00000001566 10034762451 024551 0 ustar 00mark mark 0000000 0000000 BMv v ( ` ? ? ?? ? ? ? ?? ?? ??? ? ? ?? ? ? ? ?? ??? wwwwpwwp wp ??tDDDDwwwwwwwwwwwwwww??wwwppww????????L?t?wwwtDDDDwwwtD???wpw?w?wwwwx??w???GxDDDGwL?t?wwL???wp{?pw?wp x??y?????DGLDwtGxDwwwtI???{????????????? ?p?Gww??Gwwww ???{??xpp ?p ???p ??wwp ?pwwwp ???????x???????? ?pwwwp ??wwp ??? ??x?www?x???? ????w ?pwww ???????x?DDG?x???? ???w ???ww ????x?w?x??G?x???? ???pw ??ww ???x?xx???G?x??? ?|pw ?www ??ww?w??x??G?x??G?p ?w ?ww ?wwwx?wx? ?x? ?w ?pwp wwp wwww??wx??????x??????wp ww www wwwwx?w?www?w?www?wwwp wwp wwwwp wwwwwww??x???wx???wwww wwwwwwwwwwwwwwww commons-daemon-1.1.0-native-src/windows/resources/commons.bmp 0100664 0001750 0001750 00000061566 11130065457 024706 0 ustar 00mark mark 0000000 0000000 BMvc 6 ( ? 0 @_ ? ? H / &$ 2) ! &O 91 U <