1 /* cacaoh.c - main for header generation (cacaoh)
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5 M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6 P. Tomsich, J. Wenninger
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
33 $Id: cacaoh.c 1543 2004-11-18 12:20:19Z twisti $
50 #include "threads/thread.h"
51 #include "toolbox/logging.h"
52 #include "toolbox/memory.h"
55 /* define cacaoh options ******************************************************/
60 #define OPT_DIRECTORY 5
63 { "help", false, OPT_HELP },
64 { "version", false, OPT_VERSION },
65 { "verbose", false, OPT_VERBOSE },
66 { "d", true, OPT_DIRECTORY },
71 /* usage ***********************************************************************
73 Obviously prints usage information of cacaoh.
75 *******************************************************************************/
79 printf("Usage: cacaoh [options] <classes>\n"
82 " -help Print this message\n"
83 " -version Print version information\n"
84 " -verbose Enable verbose output\n"
85 " -d <dir> Output directory\n");
87 /* exit with error code */
95 printf("cacaoh "VERSION"\n");
100 /* main ************************************************************************
104 *******************************************************************************/
106 int main(int argc, char **argv)
113 /********** internal (only used by main) *****************************/
115 char classpath[500] = "";
116 u4 heapmaxsize = 2 * 1024 * 1024;
117 u4 heapstartsize = 100 * 1024;
120 /************ Collect some info from the environment *****************/
125 cp = getenv("CLASSPATH");
127 strcpy(classpath + strlen(classpath), ":");
128 strcpy(classpath + strlen(classpath), cp);
131 /* initialize options with default values */
134 opt_directory = NULL;
136 while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
154 opt_directory = MNEW(char, strlen(opt_arg));
155 strcpy(opt_directory, opt_arg);
163 /**************************** Program start **************************/
167 log_text("Java - header-generator started");
170 /* initialize the garbage collector */
171 gc_init(heapmaxsize, heapstartsize);
175 suck_init(classpath);
177 #if defined(USE_THREADS)
178 #if defined(NATIVE_THREADS)
187 /*********************** Load JAVA classes **************************/
189 nativemethod_chain = chain_new();
190 nativeclass_chain = chain_new();
192 for (a = opt_ind; a < argc; a++) {
195 /* convert classname */
196 for (i = strlen(cp) - 1; i >= 0; i--) {
204 c = class_new(utf_new_char(cp));
206 /* exceptions are catched with new_exception call */
210 headerfile_generate(c, opt_directory);
213 /************************ Release all resources **********************/
216 tables_close(literalstring_free);
219 log_text("Java - header-generator stopped");
229 * These are local overrides for various environment variables in Emacs.
230 * Please do not remove this and leave it at the end of the file, where
231 * Emacs will automagically detect them.
232 * ---------------------------------------------------------------------
235 * indent-tabs-mode: t