/* wydawca - automatic release submission daemon Copyright (C) 2007, 2009 Sergey Poznyakoff Wydawca 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 of the License, or (at your option) any later version. Wydawca 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 wydawca. If not, see . */ static struct obstack pp_cmd_stack; static int pp_cmd_stack_init; static gl_list_t source_list; static gl_list_t tag_list; static bool string_eq (const void *elt1, const void *elt2) { return strcmp ((const char *)elt1, (const char *)elt2) == 0; } int enabled_spool_p (const struct spool *spool) { if (source_list || tag_list) return (source_list && gl_list_search (source_list, spool->source_dir)) || (tag_list && gl_list_search (tag_list, spool->tag)); return 1; } OPTIONS_BEGIN(gnu, "wydawca", [], []) GROUP(Selecting program mode) OPTION(lint,t,, []) BEGIN lint_mode = 1; log_to_stderr = 1; END OPTION(,E,, []) BEGIN preprocess_only = 1; END OPTION(dry-run,n,, []) BEGIN log_to_stderr = 1; debug_level++; dry_run_mode = 1; END OPTION(cron,,, []) BEGIN cron_option = 1; log_to_stderr = 0; END OPTION(force,,, []) BEGIN force_startup = 1; END OPTION(foreground,,, []) BEGIN foreground_option = 1; END OPTION(single-process,,, []) BEGIN single_process_option = 1; END OPTION(config-file,c,FILE, []) BEGIN conffile = optarg; END OPTION(spool,S,TAG, []) BEGIN if (!tag_list) tag_list = gl_list_create_empty (&gl_linked_list_implementation, string_eq, NULL, NULL, false); gl_list_add_last (tag_list, optarg); END OPTION(source,s,SOURCE-DIR, []) BEGIN if (!source_list) source_list = gl_list_create_empty (&gl_linked_list_implementation, string_eq, NULL, NULL, false); gl_list_add_last (source_list, optarg); END GROUP(Logging) OPTION(syslog,,, []) BEGIN log_to_stderr = 0; END OPTION(stderr,e,, []) BEGIN log_to_stderr = 1; END GROUP(Preprocessor control) OPTION(include-directory,I,DIR, []) BEGIN gconf_preproc_add_include_dir (optarg); END OPTION(define,D,SYMBOL[=VALUE], []) BEGIN char *p; if (!pp_cmd_stack_init) { obstack_init (&pp_cmd_stack); pp_cmd_stack_init = 1; } obstack_grow (&pp_cmd_stack, " \"-D", 4); for (p = optarg; *p; p++) { if (*p == '\\' || *p == '"') obstack_1grow (&pp_cmd_stack, '\\'); obstack_1grow (&pp_cmd_stack, *p); } obstack_1grow (&pp_cmd_stack, '"'); END OPTION(preprocessor,,COMMAND, []) BEGIN gconf_preprocessor = optarg; END OPTION(no-preprocessor,,, []) BEGIN gconf_preprocessor = NULL; END GROUP(Debugging) OPTION(debug,d,, []) BEGIN debug_level++; END OPTION(dump-grammar-trace,,, []) BEGIN gconf_gram_trace (1); END OPTION(dump-lex-trace,,, []) BEGIN gconf_lex_trace (1); END GROUP([]) OPTION(config-help,,, []) BEGIN config_help (); exit (0); END OPTIONS_END void parse_options(int argc, char *argv[]) { GETOPT(argc, argv) if (pp_cmd_stack_init && gconf_preprocessor) { char *defs = obstack_finish (&pp_cmd_stack); char *cmd = xmalloc (strlen (gconf_preprocessor) + strlen (defs) + 1); strcpy (cmd, gconf_preprocessor); strcat (cmd, defs); gconf_preprocessor = cmd; obstack_free (&pp_cmd_stack, NULL); } }