aboutsummaryrefslogtreecommitdiff
path: root/src/cmdline.opt
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-19 11:28:28 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-09-19 18:30:01 +0300
commit1153970626892573e5966e135e8d81185f4ea53c (patch)
tree773fdf5a8d00ec2ef752c3a8fd5f32c79829cf23 /src/cmdline.opt
downloadeclat-1153970626892573e5966e135e8d81185f4ea53c.tar.gz
eclat-1153970626892573e5966e135e8d81185f4ea53c.tar.bz2
Initial commit
Diffstat (limited to 'src/cmdline.opt')
-rw-r--r--src/cmdline.opt226
1 files changed, 226 insertions, 0 deletions
diff --git a/src/cmdline.opt b/src/cmdline.opt
new file mode 100644
index 0000000..25dc542
--- /dev/null
+++ b/src/cmdline.opt
@@ -0,0 +1,226 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Eclat is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_GETOPT_H
+# include <getopt.h>
+#endif
+
+static char *pp_cmd_buffer;
+static size_t pp_cmd_bufsize;
+static size_t pp_cmd_buflevel;
+
+struct replvar {
+ char **s_ptr;
+ char *s_val;
+};
+
+int
+replace_string_var(void *p)
+{
+ struct replvar *rv = p;
+ *rv->s_ptr = rv->s_val;
+ return 0;
+}
+
+OPTIONS_BEGIN("eclat",
+ [<EC2 Command Line Administrator Tool>],[<>],
+ [<gnu>],
+ [<copyright_year=2012>],
+ [<copyright_holder=Sergey Poznyakoff>])
+
+GROUP(Selecting program mode)
+
+OPTION(lint,t,,
+ [<parse configuration file and exit>])
+BEGIN
+ lint_mode = 1;
+END
+
+OPTION(,E,,
+ [<preprocess config and exit>])
+BEGIN
+ preprocess_only = 1;
+END
+
+OPTION(dry-run,n,,
+ [<do nothing, print almost everything>])
+BEGIN
+ dry_run_mode = 1;
+END
+
+OPTION(config-file,c,FILE,
+ [<use FILE instead of the default configuration>])
+BEGIN
+ conffile = optarg;
+END
+
+GROUP(Commands)
+
+OPTION(start-instances,,,
+ [<Start named instances>])
+BEGIN
+ eclat_command = eclat_command_start_instances;
+END
+
+OPTION(stop-instances,,,
+ [<Stop named instances>])
+BEGIN
+ eclat_command = eclat_command_stop_instances;
+END
+
+GROUP(Modifiers)
+
+OPTION(region,,NAME,
+ [<define AWS region>])
+BEGIN
+ struct replvar *rv = grecs_malloc(sizeof(*rv));
+ rv->s_ptr = &region_name;
+ rv->s_val = optarg;
+ add_config_finish_hook(replace_string_var, rv);
+END
+
+OPTION(access-file,a,NAME,
+ [<set access file>])
+BEGIN
+ struct replvar *rv = grecs_malloc(sizeof(*rv));
+ rv->s_ptr = &access_file_name;
+ rv->s_val = optarg;
+ add_config_finish_hook(replace_string_var, rv);
+END
+
+OPTION(access-key,O,KEY,
+ [<set access key to use>])
+BEGIN
+ access_key = optarg;
+END
+
+OPTION(secret-key,W,KEY,
+ [<set secret key to use>])
+BEGIN
+ secret_key = optarg;
+END
+
+OPTION(ssl,,,
+ [<use SSL (HTTPS) connection>])
+BEGIN
+ use_ssl = 1;
+END
+
+GROUP(Preprocessor control)
+
+OPTION(include-directory,I,DIR,
+ [<add include directory>])
+BEGIN
+ grecs_preproc_add_include_dir(optarg);
+END
+
+OPTION(define,D,SYMBOL[=VALUE],
+ [<define a preprocessor symbol>])
+BEGIN
+ size_t len;
+ char *p;
+
+ len = 4;
+ for (p = optarg; *p; p++) {
+ if (*p == '\\' || *p == '"')
+ len++;
+ len++;
+ }
+
+ if (pp_cmd_buflevel + len + 1 > pp_cmd_bufsize) {
+ pp_cmd_bufsize = pp_cmd_buflevel + len + 1;
+ pp_cmd_buffer = grecs_realloc(pp_cmd_buffer, pp_cmd_bufsize);
+ }
+ memcpy(pp_cmd_buffer + pp_cmd_buflevel, " \"-D", 4);
+ pp_cmd_buflevel += 4;
+
+ p = optarg;
+ do {
+ if (*p == '\\' || *p == '"')
+ pp_cmd_buffer[pp_cmd_buflevel++] = '\\';
+ pp_cmd_buffer[pp_cmd_buflevel++] = *p;
+ } while (*p++);
+END
+
+OPTION(preprocessor,,COMMAND,
+ [<use COMMAND instead of the default preprocessor>])
+BEGIN
+ grecs_preprocessor = optarg;
+END
+
+OPTION(no-preprocessor,,,
+ [<disable preprocessing>])
+BEGIN
+ grecs_preprocessor = NULL;
+END
+
+GROUP(Debugging)
+
+OPTION(dump-grammar-trace,,,
+ [<dump configuration grammar traces>])
+BEGIN
+ grecs_gram_trace (1);
+END
+
+OPTION(dump-lex-trace,,,
+ [<dump lexical analyzer traces>])
+BEGIN
+ grecs_lex_trace (1);
+END
+
+OPTION(debug,d,CAT[.LEVEL],
+ [<set debugging level>])
+BEGIN
+ if (parse_debug_level(optarg)) {
+ die(EX_USAGE, "invalid debugging category or level");
+ }
+END
+
+GROUP([<Additional help>])
+OPTION(config-help,,,
+ [<show configuration file summary>])
+BEGIN
+ config_help();
+ exit(0);
+END
+
+OPTIONS_END
+
+void
+set_program_name(const char *arg)
+{
+ program_name = strrchr(arg, '/');
+ if (!program_name)
+ program_name = arg;
+ else
+ program_name++;
+}
+
+void
+parse_options(int argc, char *argv[], int *index)
+{
+ GETOPT(argc, argv, *index, exit(EX_USAGE))
+
+ if (pp_cmd_buffer && grecs_preprocessor) {
+ char *cmd = grecs_malloc(strlen(grecs_preprocessor) +
+ pp_cmd_buflevel + 1);
+ strcpy(cmd, grecs_preprocessor);
+ strcat(cmd, pp_cmd_buffer);
+ grecs_preprocessor = cmd;
+ free(pp_cmd_buffer);
+ }
+}
+

Return to:

Send suggestions and report system problems to the System administrator.