harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyd...@apache.org
Subject svn commit: r565131 - /harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvmargv.c
Date Sun, 12 Aug 2007 20:15:32 GMT
Author: dlydick
Date: Sun Aug 12 13:15:32 2007
New Revision: 565131

URL: http://svn.apache.org/viewvc?view=rev&rev=565131
Log:
Renamed 'argv.c' to 'jvmargv.c'

Added (boolean *) paramter to jvmargv_init() to declare that the
JVM is completely initialized.

Broke out argv_licensemsg(), argv_versionmsg() and argv_copyrightmsg()
into jvmutil_xxx() equivalents for anticipating construction of
utilities.

Simplify default CLASSPATH and BOOTCLASSPATH calculations.

Added:
    harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvmargv.c
      - copied, changed from r490327, harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/argv.c

Copied: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvmargv.c (from r490327, harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/argv.c)
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvmargv.c?view=diff&rev=565131&p1=harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/argv.c&r1=490327&p2=harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvmargv.c&r2=565131
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/argv.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvmargv.c Sun Aug 12 13:15:32 2007
@@ -1,5 +1,5 @@
 /*!
- * @file argv.c
+ * @file jvmargv.c
  *
  * @brief Process command line arguments passed in to JVM program.
  *
@@ -22,7 +22,12 @@
  * to always be unchanged.
  *
  * The tmparea_init() function must have been called before these
- * functions so the internal @b CLASSPATH can be set up properly.
+ * functions so the internal @b CLASSPATH can be set up properly, but
+ * beforehand, but only if the @link #JVMCFG_TMPAREA_IN_USE@endlink
+ * will be used.  (Notice that one of the parameters to this function
+ * is the heap allocation and free method to be used.  This way it may
+ * be called from both the JVM and utility functions unchanged, even
+ * when the utilities do not use the same heap mechanism as the JVM.)
  *
  *
  * @section Control
@@ -61,7 +66,7 @@
  */
 
 #include "arch.h"
-ARCH_SOURCE_COPYRIGHT_APACHE(argv, c,
+ARCH_SOURCE_COPYRIGHT_APACHE(jvmargv, c,
 "$URL$",
 "$Id$");
 
@@ -117,19 +122,27 @@
  * the starting class name are passed to the JVM as '(String) args[]'.
  *
  *
- * @param argc    Number of arguments on command line
+ * @param[in]  argc            Number of arguments on command line
  *
- * @param argv    Argument vector from the command line
+ * @param[in]  argv            Argument vector from the command line
  *
- * @param envp    Environment pointer from command line environ
+ * @param[in]  envp            Environment pointer from command line
+ *
+ * @param[out] argv_init_flag  Pointer to rboolean, changed to
+ *                             @link #rtrue rtrue@endlink
+ *                             to indicate argument vector
+ *                             area now available.
  *
  *
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid argv_init(int argc, char **argv, char **envp)
+rvoid jvmargv_init(int        argc,
+                   char     **argv,
+                   char     **envp,
+                   rboolean  *argv_init_flag)
 {
-    ARCH_FUNCTION_NAME(argv_init);
+    ARCH_FUNCTION_NAME(jvmargv_init);
 
     rint     argclocal = (rint)     argc;
     rchar ** argvlocal = (rchar **) argv;
@@ -193,7 +206,7 @@
         if (0 == portable_strcmp(JVMCFG_COMMAND_LINE_HELP_PARM,
                                  argvlocal[i]))
         {
-            argv_helpmsg();
+            jvmargv_helpmsg();
             exit_jvm(EXIT_ARGV_HELP);
 /*NOTREACHED*/
         }
@@ -201,7 +214,7 @@
         if (0 == portable_strcmp(JVMCFG_COMMAND_LINE_LICENSE_PARM,
                                  argvlocal[i]))
         {
-            argv_licensemsg();
+            jvmutil_licensemsg();
             exit_jvm(EXIT_ARGV_LICENSE);
 /*NOTREACHED*/
         }
@@ -209,7 +222,7 @@
         if (0 == portable_strcmp(JVMCFG_COMMAND_LINE_VERSION_PARM,
                                  argvlocal[i]))
         {
-            argv_versionmsg();
+            jvmutil_versionmsg();
             exit_jvm(EXIT_ARGV_VERSION);
 /*NOTREACHED*/
         }
@@ -217,7 +230,7 @@
         if (0 == portable_strcmp(JVMCFG_COMMAND_LINE_COPYRIGHT_PARM,
                                  argvlocal[i]))
         {
-            argv_copyrightmsg();
+            jvmutil_copyrightmsg();
             exit_jvm(EXIT_ARGV_COPYRIGHT);
 /*NOTREACHED*/
         }
@@ -305,6 +318,11 @@
 
                 i++;
             }
+            else
+            {
+                sysErrMsg(arch_function_name,
+                      "missing debug message level.  Request ignored.");
+            }
         }
         else
         /*
@@ -388,132 +406,64 @@
                         sizeof(rchar) + portable_strlen(chkjh));
     }
 
-    /* Try to get a valid @b CLASSPATH even if not found elsewhere */
-    chkcp = (rchar *) ((rnull == chkcp)
-                         ? JVMCFG_CLASSPATH_DEFAULT
-                         : (const rchar *) chkcp);
-
-    pjvm->classpath = (rchar *) rnull;
-    if (rnull != chkcp)
+    /* Get a valid default @b CLASSPATH even if not found elsewhere */
+    if (rnull == chkcp)
     {
-        /* Copy '\0' byte also */
-        pjvm->classpath =
-            HEAP_GET_DATA(sizeof(rchar) + portable_strlen(chkcp),
-                          rfalse);
-
-        portable_memcpy(pjvm->classpath,
-                        chkcp, 
-                        sizeof(rchar) + portable_strlen(chkcp));
+        chkcp = (rchar *) JVMCFG_CLASSPATH_DEFAULT;
     }
+
+    /* Copy '\0' byte also */
+    pjvm->classpath =
+        HEAP_GET_DATA(sizeof(rchar) + portable_strlen(chkcp), rfalse);
+
+    portable_memcpy(pjvm->classpath,
+                    chkcp, 
+                    sizeof(rchar) + portable_strlen(chkcp));
+
 #ifdef JVMCFG_HARDCODED_TEST_CLASSPATH
+    /* Only use for initial development-- a heap leakage bug otherwise*/
     pjvm->classpath = JVMCFG_HARDCODED_TEST_CLASSPATH;
 #endif
 
-    /* Try to get a valid @b BOOTCLASSPATH even if not found elsewhere*/
-    chkbcp = (rchar *) ((rnull == chkbcp)
-                          ?
+    /* Get valid default @b BOOTCLASSPATH even if not found elsewhere*/
+    if (rnull == chkbcp)
+    {
 #ifdef CONFIG_HACKED_BOOTCLASSPATH
-                            JVMCFG_CLASSPATH_DEFAULT
+        chkbcp = (rchar *) JVMCFG_CLASSPATH_DEFAULT;
 #else
-                            JVMCFG_BOOTCLASSPATH_DEFAULT
+        chkbcp = (rchar *) JVMCFG_BOOTCLASSPATH_DEFAULT;
 #endif
-                          : (const rchar *) chkbcp);
+    }
 
     pjvm->bootclasspath = (rchar *) rnull;
-    if (rnull != chkbcp)
-    {
-        /* Copy '\0' byte also */
-        pjvm->bootclasspath =
-          HEAP_GET_DATA(sizeof(rchar) + portable_strlen(chkbcp),rfalse);
 
-        portable_memcpy(pjvm->bootclasspath,
-                        chkbcp,
-                        sizeof(rchar) + portable_strlen(chkbcp));
-    }
+    /* Copy '\0' byte also */
+    pjvm->bootclasspath =
+      HEAP_GET_DATA(sizeof(rchar) + portable_strlen(chkbcp),rfalse);
+
+    portable_memcpy(pjvm->bootclasspath,
+                    chkbcp,
+                    sizeof(rchar) + portable_strlen(chkbcp));
+
+    /* Declare this module initialized */
+    *argv_init_flag = rtrue;
 
-    /* Show summary of what command line resoved into */
+    /* Show summary of what command line resolved into */
     if (rtrue == show_flag)
     {
-        argv_showmsg();
+        jvmargv_showmsg();
+        jvmargv_shutdown(argv_init_flag);
+        exit_jvm(EXIT_ARGV_SHOW);
     }
 
     /* Display copyright msg and finish */
-    argv_copyrightmsg();
-
-    /* Declare this module initialized */
-    jvm_argv_initialized = rtrue;
-
-    return;
-
-} /* END of argv_init() */
-
-
-/*!
- * @brief Show program version message to standard output.
- *
- *
- * @b Parameters: @link #rvoid rvoid@endlink
- *
- *
- * @returns @link #rvoid rvoid@endlink
- *
- */
-rvoid argv_versionmsg(rvoid)
-{
-    ARCH_FUNCTION_NAME(argv_versionmsg);
-
-    fprintfLocalStdout("%s\n", CONFIG_RELEASE_LEVEL);
-
-    return;
-
-} /* END of argv_versionmsg() */
-
-
-/*!
- * @brief Show program copyright message to standard output.
- *
- *
- * @b Parameters: @link #rvoid rvoid@endlink
- *
- *
- * @returns @link #rvoid rvoid@endlink
- *
- */
-rvoid argv_copyrightmsg(rvoid)
-{
-    ARCH_FUNCTION_NAME(argv_copyrightmsg);
-
-    fprintfLocalStdout("\n%s:  %s, version %s\n%s\n\n",
-                       CONFIG_PROGRAM_NAME,
-                       CONFIG_PROGRAM_DESCRIPTION,
-                       CONFIG_RELEASE_LEVEL,
-                       ARCH_COPYRIGHT_TEXT_APACHE);
-
-    return;
-
-} /* END of argv_copyrightmsg() */
-
-
-/*!
- * @brief Show program software license message to standard output.
- *
- *
- * @b Parameters: @link #rvoid rvoid@endlink
- *
- *
- * @returns @link #rvoid rvoid@endlink
- *
- */
-rvoid argv_licensemsg(rvoid)
-{
-    ARCH_FUNCTION_NAME(argv_licensemsg);
-
-    argv_copyrightmsg();
-    fprintfLocalStdout("%s\n\n", ARCH_LICENSE_TEXT_APACHE);
+#if 0
+    jvmutil_copyrightmsg();
+#endif
 
     return;
 
-} /* END of argv_licensemsg() */
+} /* END of jvmargv_init() */
 
 
 #define LEADING_SPACES "                  "
@@ -528,11 +478,11 @@
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid argv_helpmsg(rvoid)
+rvoid jvmargv_helpmsg(rvoid)
 {
-    ARCH_FUNCTION_NAME(argv_helpmsg);
+    ARCH_FUNCTION_NAME(jvmargv_helpmsg);
 
-    argv_copyrightmsg();
+    jvmutil_copyrightmsg();
 
     fprintfLocalStdout(
 "%s:  version %s\n\n",
@@ -568,26 +518,6 @@
 "%snot supported for locating this class name.\n\n",
                        LEADING_SPACES);
 
-    fprintfLocalStdout("    %s         %s",
-                       JVMCFG_COMMAND_LINE_SHOW_PARM,
-   "Show how command line and environment resolves after parsing.\n");
-    fprintfLocalStdout("    %s      %s",
-                       JVMCFG_COMMAND_LINE_VERSION_PARM,
-   "Display the program release level.\n");
-
-    fprintfLocalStdout("    %s    %s",
-                       JVMCFG_COMMAND_LINE_COPYRIGHT_PARM,
-   "Display the program copyright.\n");
-
-    fprintfLocalStdout("    %s      %s",
-                       JVMCFG_COMMAND_LINE_LICENSE_PARM,
-   "Display the program software license.\n");
-
-    fprintfLocalStdout("    %s         %s",
-                       JVMCFG_COMMAND_LINE_HELP_PARM,
-   "Display this help message.\n\n");
-
-
     fprintfLocalStdout("    %s pathname\n", JVMCFG_JAVA_HOME_FULL_PARM);
     fprintfLocalStdout("    %s  pathname\n", JVMCFG_JAVA_HOME_MID_PARM);
     fprintfLocalStdout(
@@ -652,9 +582,15 @@
 "    args          Optional arguments to pass to JVM, if any.\n\n");
 
 
+    argvutil_common_msghdr();
+
+    argvutil_jvm_showmsg();
+
+    argvutil_common_msgs();
+
     return;
 
-} /* END of argv_helpmsg() */
+} /* END of jvmargv_helpmsg() */
 
 
 /*!
@@ -667,9 +603,9 @@
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid argv_showmsg(rvoid)
+rvoid jvmargv_showmsg(rvoid)
 {
-    ARCH_FUNCTION_NAME(argv_showmsg);
+    ARCH_FUNCTION_NAME(jvmargv_showmsg);
 
     fprintfLocalStdout("JAVA_HOME=%s\n", pjvm->java_home);
 
@@ -697,9 +633,7 @@
         ; /* Simply count number of args, terminated by rnull slot */
     }
 
-    fprintfLocalStdout("argc=%d\n", argc);
-
-    fprintfLocalStdout("args=");
+    fprintfLocalStdout("\n%d args: ", argc);
 
     rint i;
     for (i = 0; i < argc; i++)
@@ -713,22 +647,25 @@
 
     return;
 
-} /* END of argv_showmsg() */
+} /* END of jvmargv_showmsg() */
 
 
 /*!
  * @brief Clean up from argv[] setup after JVM execution.
  *
  *
- * @b Parameters: @link #rvoid rvoid@endlink
+ * @param[out]   argv_init_flag   Pointer to rboolean, changed to
+ *                                @link #rtrue rtrue@endlink
+ *                                to indicate argument vector
+ *                                no longer available.
  *
  *
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid argv_shutdown(rvoid)
+rvoid jvmargv_shutdown(rboolean *argv_init_flag)
 {
-    ARCH_FUNCTION_NAME(argv_shutdown);
+    ARCH_FUNCTION_NAME(jvmargv_shutdown);
 
     HEAP_FREE_DATA(pjvm->bootclasspath);
     pjvm->bootclasspath = (rchar *) rnull;
@@ -748,11 +685,11 @@
     pjvm->argvj = (rchar **) rnull;
 
     /* Declare this module uninitialized */
-    jvm_argv_initialized = rfalse;
+    *argv_init_flag = rfalse;
 
     return;
 
-} /* END of argv_shutdown() */
+} /* END of jvmargv_shutdown() */
 
 
 /* EOF */



Mime
View raw message