X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=options.c;h=6c2d93a9931e3010c6e5255d3f5a3b2979e6c83a;hb=5e437babf999f56443016da5b25f7ad410b7e8f2;hp=c8f1b9ff8820f2edc06a64f4c15daa0c24648f6a;hpb=b751460674c97e929128f1c35a44079b66db8958;p=cacao.git diff --git a/options.c b/options.c index c8f1b9ff8..6c2d93a99 100644 --- a/options.c +++ b/options.c @@ -27,12 +27,14 @@ Authors: Christian Thalinger - $Id: options.c 1474 2004-11-11 10:09:10Z carolyn $ + $Id: options.c 1529 2004-11-17 17:19:14Z twisti $ */ -#include "global.h" +#include +#include "options.h" +#include "types.h" /* command line option */ @@ -88,6 +90,62 @@ bool opt_verify = true; /* true if classfiles should be verified */ bool opt_eager = false; +int opt_ind = 1; /* index of processed arguments */ +char *opt_arg; /* this one exports the option argument */ + + +/* get_opt ********************************************************************* + + DOCUMENT ME!!! + +*******************************************************************************/ + +int get_opt(int argc, char **argv, opt_struct *opts) +{ + char *a; + int i; + + if (opt_ind >= argc) + return OPT_DONE; + + a = argv[opt_ind]; + if (a[0] != '-') + return OPT_DONE; + + for (i = 0; opts[i].name; i++) { + if (!opts[i].arg) { + if (strcmp(a + 1, opts[i].name) == 0) { /* boolean option found */ + opt_ind++; + return opts[i].value; + } + + } else { + if (strcmp(a + 1, opts[i].name) == 0) { /* parameter option found */ + opt_ind++; + if (opt_ind < argc) { + opt_arg = argv[opt_ind]; + opt_ind++; + return opts[i].value; + } + return OPT_ERROR; + + } else { + size_t l = strlen(opts[i].name); + if (strlen(a + 1) > l) { + if (memcmp(a + 1, opts[i].name, l) == 0) { + opt_ind++; + opt_arg = a + 1 + l; + return opts[i].value; + } + } + } + } + } /* end for */ + + return OPT_ERROR; +} + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where