]>
Commit | Line | Data |
---|---|---|
2ba5f774 | 1 | /* Copyright (C) 1999 Free Software Foundation |
58eb6e7c AG |
2 | |
3 | This file is part of libgcj. | |
4 | ||
5 | This software is copyrighted work licensed under the terms of the | |
6 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for | |
7 | details. */ | |
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> |
58eb6e7c AG |
19 | |
20 | #include <java/lang/System.h> | |
21 | #include <java/util/Properties.h> | |
22 | ||
b8c3c4f0 TT |
23 | static void |
24 | help () | |
25 | { | |
26 | printf ("Usage: gij [OPTION] ... CLASS [ARGS] ...\n\n"); | |
27 | printf ("Interpret Java bytecodes\n\n"); | |
28 | printf (" -DVAR=VAL define property VAR with value VAL\n"); | |
29 | printf (" --help print this help, then exit\n"); | |
30 | printf (" --ms=NUMBER set initial heap size\n"); | |
31 | printf (" --mx=NUMBER set maximum heap size\n"); | |
32 | printf (" --version print version number, then exit\n"); | |
33 | printf ("\nSee http://sourceware.cygnus.com/java/ for information on reporting bugs\n"); | |
34 | exit (0); | |
35 | } | |
36 | ||
37 | static void | |
38 | version () | |
76ed0c0a | 39 | { |
b8c3c4f0 | 40 | printf ("gij (GNU libgcj) version %s\n\n", VERSION); |
2ba5f774 | 41 | printf ("Copyright (C) 1999 Free Software Foundation.\n"); |
b8c3c4f0 TT |
42 | printf ("This is free software; see the source for copying conditions. There is NO\n"); |
43 | printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); | |
44 | exit (0); | |
45 | } | |
76ed0c0a TT |
46 | |
47 | int | |
48 | main (int argc, const char **argv) | |
58eb6e7c | 49 | { |
b8c3c4f0 TT |
50 | /* We rearrange ARGV so that all the -D options appear near the |
51 | beginning. */ | |
52 | int last_D_option = 0; | |
53 | ||
54 | int i; | |
55 | for (i = 1; i < argc; ++i) | |
56 | { | |
57 | const char *arg = argv[i]; | |
58 | ||
59 | /* A non-option stops processing. */ | |
60 | if (arg[0] != '-') | |
61 | break; | |
62 | /* A "--" stops processing. */ | |
63 | if (! strcmp (arg, "--")) | |
64 | { | |
65 | ++i; | |
66 | break; | |
67 | } | |
68 | ||
69 | if (! strncmp (arg, "-D", 2)) | |
70 | { | |
71 | argv[last_D_option++] = arg + 2; | |
72 | continue; | |
73 | } | |
74 | ||
75 | /* Allow both single or double hyphen for all remaining | |
76 | options. */ | |
77 | if (arg[1] == '-') | |
78 | ++arg; | |
79 | ||
80 | if (! strcmp (arg, "-help")) | |
81 | help (); | |
82 | else if (! strcmp (arg, "-version")) | |
83 | version (); | |
84 | /* FIXME: use getopt and avoid the ugliness here. | |
85 | We at least need to handle the argument in a better way. */ | |
86 | else if (! strncmp (arg, "-ms=", 4)) | |
87 | _Jv_SetInitialHeapSize (arg + 4); | |
88 | else if (! strcmp (arg, "-ms")) | |
89 | { | |
90 | if (i >= argc - 1) | |
91 | { | |
3cf88fb4 | 92 | no_arg: |
b8c3c4f0 TT |
93 | fprintf (stderr, "gij: option requires an argument -- `%s'\n", |
94 | argv[i]); | |
95 | fprintf (stderr, "Try `gij --help' for more information.\n"); | |
96 | exit (1); | |
97 | } | |
98 | _Jv_SetInitialHeapSize (argv[++i]); | |
99 | } | |
100 | else if (! strncmp (arg, "-mx=", 4)) | |
101 | _Jv_SetMaximumHeapSize (arg + 4); | |
102 | else if (! strcmp (arg, "-mx")) | |
103 | { | |
104 | if (i >= argc - 1) | |
3cf88fb4 | 105 | goto no_arg; |
b8c3c4f0 TT |
106 | _Jv_SetMaximumHeapSize (argv[++i]); |
107 | } | |
108 | else | |
109 | { | |
110 | fprintf (stderr, "gij: unrecognized option -- `%s'\n", argv[i]); | |
111 | fprintf (stderr, "Try `gij --help' for more information.\n"); | |
112 | exit (1); | |
113 | } | |
114 | } | |
115 | ||
116 | argv[last_D_option] = NULL; | |
117 | _Jv_Compiler_Properties = argv; | |
118 | ||
119 | if (argc - i < 1) | |
58eb6e7c | 120 | { |
b8c3c4f0 TT |
121 | fprintf (stderr, "Usage: gij [OPTION] ... CLASS [ARGS] ...\n"); |
122 | fprintf (stderr, "Try `gij --help' for more information.\n"); | |
58eb6e7c AG |
123 | exit (1); |
124 | } | |
125 | ||
b8c3c4f0 | 126 | _Jv_RunMain (argv[i], argc - i, argv + i); |
58eb6e7c | 127 | } |