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