You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2019/05/28 09:46:55 UTC

svn commit: r1860225 [3/16] - in /tomee/deps/branches/commons-daemon: ./ src/ src/assembly/ src/changes/ src/docs/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/commons/ src/main/java/org/apache/commons/...

Added: tomee/deps/branches/commons-daemon/src/native/unix/configure.in
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/configure.in?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/configure.in (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/configure.in Tue May 28 09:46:53 2019
@@ -0,0 +1,145 @@
+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 <ma...@eng.sun.com>
+dnl Version $Id$
+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"])

Added: tomee/deps/branches/commons-daemon/src/native/unix/man/README
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/man/README?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/man/README (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/man/README Tue May 28 09:46:53 2019
@@ -0,0 +1,20 @@
+To build it use:
+docbook2man jsvc.1.xml
+
+If your docbook2man uses xalan and you are behind a firewall
+Modify jsvc.1.xml as below:
++++
+Index: jsvc.1.xml
+===================================================================
+--- jsvc.1.xml	(revision 170004)
++++ jsvc.1.xml	(working copy)
+@@ -1,6 +1,6 @@
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+-                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
++                   "docbookx.dtd">
+ <refentry id='jsvc1'>
+   <refmeta>
+     <refentrytitle>JSVC</refentrytitle>
++++
+Use fetch.sh to get docbook files.

Added: tomee/deps/branches/commons-daemon/src/native/unix/man/fetch.sh
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/man/fetch.sh?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/man/fetch.sh (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/man/fetch.sh Tue May 28 09:46:53 2019
@@ -0,0 +1,36 @@
+# 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

Added: tomee/deps/branches/commons-daemon/src/native/unix/man/jsvc.1.xml
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/man/jsvc.1.xml?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/man/jsvc.1.xml (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/man/jsvc.1.xml Tue May 28 09:46:53 2019
@@ -0,0 +1,223 @@
+<?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.1</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 '&amp;2' to simulate
+            '1&gt;&amp;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 '&amp;1' to simulate
+            '2&gt;&amp;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>&lt;name&gt;=&lt;value&gt;</term>
+        <listitem>
+          <para>set a Java system property</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-X</option>&lt;option&gt;</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>

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/.gitignore
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/.gitignore?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/.gitignore (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/.gitignore Tue May 28 09:46:53 2019
@@ -0,0 +1,3 @@
+/Makefile
+/*.o
+/libservice.a

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/.indent.pro
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/.indent.pro?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/.indent.pro (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/.indent.pro Tue May 28 09:46:53 2019
@@ -0,0 +1,7 @@
+-i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1 -nut -ncs
+-Tbool
+-Targ_data
+-Thome_data
+-Thome_jvm
+-Tdso_handle
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/Makefile.in
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/Makefile.in?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/Makefile.in (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/Makefile.in Tue May 28 09:46:53 2019
@@ -0,0 +1,43 @@
+#
+# 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
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.c
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.c?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.c (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.c Tue May 28 09:46:53 2019
@@ -0,0 +1,523 @@
+/* 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;
+}
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.h
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.h?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.h (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/arguments.h Tue May 28 09:46:53 2019
@@ -0,0 +1,97 @@
+/* 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__ */
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/debug.c
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/debug.c?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/debug.c (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/debug.c Tue May 28 09:46:53 2019
@@ -0,0 +1,86 @@
+/* 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);
+}
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/debug.h
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/debug.h?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/debug.h (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/debug.h Tue May 28 09:46:53 2019
@@ -0,0 +1,64 @@
+/* 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__ */
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dlfcn.c
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dlfcn.c?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dlfcn.c (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dlfcn.c Tue May 28 09:46:53 2019
@@ -0,0 +1,61 @@
+/* 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 */
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dyld.c
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dyld.c?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dyld.c (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/dso-dyld.c Tue May 28 09:46:53 2019
@@ -0,0 +1,152 @@
+/*
+   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 publicly as NSModuleFileImage is not
+       yet implemented (at least for non MH_BUNDLE libraries */
+    if (NSAddLibrary(path) != TRUE)
+        return (NULL);
+    /* We need to return a non-null value, even if it has no meaning. One day
+       this whole crap will be fixed */
+    return ((void *)!NULL);
+}
+
+/* Attempt to unload a library */
+bool dso_unlink(dso_handle libr)
+{
+    /* Check the handle */
+    if (libr == NULL) {
+        log_error("Attempting to unload a module without handle");
+        return (false);
+    }
+
+    /* We don't have a module, so, we don't really have to do anything */
+    return (true);
+}
+
+/* Get the address for a specifed symbol */
+void *dso_symbol(dso_handle hdl, const char *nam)
+{
+    NSSymbol sym = NULL;
+    NSModule mod = NULL;
+    char *und = NULL;
+    void *add = NULL;
+    int x = 0;
+
+    /* Check parameters */
+    if (hdl == NULL) {
+        log_error("Invalid library handler specified");
+        return (NULL);
+    }
+
+    if (nam == NULL) {
+        log_error("Invalid symbol name specified");
+        return (NULL);
+    }
+
+    /* Process the correct name (add a _ before the name) */
+    while (nam[x] != '\0')
+        x++;
+    und = (char *)malloc(sizeof(char) * (x + 2));
+    while (x >= 0)
+        und[x + 1] = nam[x--];
+    und[0] = '_';
+
+    /* Find the symbol */
+    sym = NSLookupAndBindSymbol(und);
+    free(und);
+    if (sym == NULL)
+        return (NULL);
+
+    /* Dump some debugging output since this part is shaky */
+    mod = NSModuleForSymbol(sym);
+    add = NSAddressOfSymbol(sym);
+    log_debug("Symbol \"%s\" found in module \"%s\" at address \"0x%08X\"",
+              NSNameOfSymbol(sym), NSNameOfModule(mod), add);
+
+    /* We want to return the address of the symbol */
+    return (add);
+}
+
+/* Return the error message from dlopen: Well we already print it */
+char *dso_error()
+{
+    return ("no additional message");
+}
+
+#endif /* ifdef DSO_DYLD */

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/dso.h
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/dso.h?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/dso.h (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/dso.h Tue May 28 09:46:53 2019
@@ -0,0 +1,37 @@
+/* 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__ */
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/help.c
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/help.c?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/help.c (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/help.c Tue May 28 09:46:53 2019
@@ -0,0 +1,128 @@
+/* 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");
+}
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/help.h
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/help.h?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/help.h (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/help.h Tue May 28 09:46:53 2019
@@ -0,0 +1,23 @@
+/* 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__ */
+

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/home.c
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/home.c?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/home.c (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/home.c Tue May 28 09:46:53 2019
@@ -0,0 +1,269 @@
+/*
+   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);
+}

Added: tomee/deps/branches/commons-daemon/src/native/unix/native/home.h
URL: http://svn.apache.org/viewvc/tomee/deps/branches/commons-daemon/src/native/unix/native/home.h?rev=1860225&view=auto
==============================================================================
--- tomee/deps/branches/commons-daemon/src/native/unix/native/home.h (added)
+++ tomee/deps/branches/commons-daemon/src/native/unix/native/home.h Tue May 28 09:46:53 2019
@@ -0,0 +1,46 @@
+/*
+   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__ */