]> gcc.gnu.org Git - gcc.git/blame - libjava/gij.cc
* extend.texi: Update for CPP.
[gcc.git] / libjava / gij.cc
CommitLineData
f2e541ce 1/* Copyright (C) 1999, 2000 Free Software Foundation
58eb6e7c
AG
2
3 This file is part of libgcj.
4
5This software is copyrighted work licensed under the terms of the
6Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7details. */
8
9/* Author: Kresten Krab Thorup <krab@gnu.org> */
10
b8c3c4f0
TT
11#include <config.h>
12
58eb6e7c 13#include <jvm.h>
27e934d8 14#include <gcj/cni.h>
b8c3c4f0
TT
15#include <java-props.h>
16
58eb6e7c 17#include <stdio.h>
b8c3c4f0 18#include <string.h>
f1aa7a52 19#include <stdlib.h>
58eb6e7c
AG
20
21#include <java/lang/System.h>
22#include <java/util/Properties.h>
23
b8c3c4f0
TT
24static void
25help ()
26{
1a558147
AG
27 printf ("Usage: gij [OPTION] ... CLASS [ARGS] ...\n");
28 printf (" to interpret Java bytecodes, or\n");
29 printf (" gij -jar [OPTION] ... JARFILE [ARGS] ...\n");
30 printf (" to execute a jar file\n\n");
b8c3c4f0
TT
31 printf (" -DVAR=VAL define property VAR with value VAL\n");
32 printf (" --help print this help, then exit\n");
33 printf (" --ms=NUMBER set initial heap size\n");
34 printf (" --mx=NUMBER set maximum heap size\n");
35 printf (" --version print version number, then exit\n");
f2e541ce 36 printf ("\nSee http://sources.redhat.com/java/ for information on reporting bugs\n");
b8c3c4f0
TT
37 exit (0);
38}
39
40static void
41version ()
76ed0c0a 42{
b8c3c4f0 43 printf ("gij (GNU libgcj) version %s\n\n", VERSION);
f2e541ce 44 printf ("Copyright (C) 1999, 2000 Free Software Foundation.\n");
b8c3c4f0
TT
45 printf ("This is free software; see the source for copying conditions. There is NO\n");
46 printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
47 exit (0);
48}
76ed0c0a
TT
49
50int
51main (int argc, const char **argv)
58eb6e7c 52{
b8c3c4f0
TT
53 /* We rearrange ARGV so that all the -D options appear near the
54 beginning. */
55 int last_D_option = 0;
1a558147 56 bool jar_mode = false;
b8c3c4f0
TT
57
58 int i;
59 for (i = 1; i < argc; ++i)
60 {
61 const char *arg = argv[i];
62
63 /* A non-option stops processing. */
64 if (arg[0] != '-')
65 break;
66 /* A "--" stops processing. */
67 if (! strcmp (arg, "--"))
68 {
69 ++i;
70 break;
71 }
72
73 if (! strncmp (arg, "-D", 2))
74 {
75 argv[last_D_option++] = arg + 2;
76 continue;
77 }
78
1a558147
AG
79 if (! strcmp (arg, "-jar"))
80 {
81 jar_mode = true;
82 continue;
83 }
84
b8c3c4f0
TT
85 /* Allow both single or double hyphen for all remaining
86 options. */
87 if (arg[1] == '-')
88 ++arg;
89
90 if (! strcmp (arg, "-help"))
91 help ();
92 else if (! strcmp (arg, "-version"))
93 version ();
94 /* FIXME: use getopt and avoid the ugliness here.
95 We at least need to handle the argument in a better way. */
96 else if (! strncmp (arg, "-ms=", 4))
97 _Jv_SetInitialHeapSize (arg + 4);
98 else if (! strcmp (arg, "-ms"))
99 {
100 if (i >= argc - 1)
101 {
3cf88fb4 102 no_arg:
b8c3c4f0
TT
103 fprintf (stderr, "gij: option requires an argument -- `%s'\n",
104 argv[i]);
105 fprintf (stderr, "Try `gij --help' for more information.\n");
106 exit (1);
107 }
108 _Jv_SetInitialHeapSize (argv[++i]);
109 }
110 else if (! strncmp (arg, "-mx=", 4))
111 _Jv_SetMaximumHeapSize (arg + 4);
112 else if (! strcmp (arg, "-mx"))
113 {
114 if (i >= argc - 1)
3cf88fb4 115 goto no_arg;
b8c3c4f0
TT
116 _Jv_SetMaximumHeapSize (argv[++i]);
117 }
118 else
119 {
120 fprintf (stderr, "gij: unrecognized option -- `%s'\n", argv[i]);
121 fprintf (stderr, "Try `gij --help' for more information.\n");
122 exit (1);
123 }
124 }
125
126 argv[last_D_option] = NULL;
127 _Jv_Compiler_Properties = argv;
128
129 if (argc - i < 1)
58eb6e7c 130 {
b8c3c4f0 131 fprintf (stderr, "Usage: gij [OPTION] ... CLASS [ARGS] ...\n");
1a558147
AG
132 fprintf (stderr, " to interpret Java bytecodes, or\n");
133 fprintf (stderr, " gij -jar [OPTION] ... JARFILE [ARGS] ...\n");
134 fprintf (stderr, " to execute a jar file\n");
b8c3c4f0 135 fprintf (stderr, "Try `gij --help' for more information.\n");
58eb6e7c
AG
136 exit (1);
137 }
138
1a558147 139 _Jv_RunMain (argv[i], argc - i, argv + i, jar_mode);
58eb6e7c 140}
This page took 0.141801 seconds and 5 git commands to generate.