/* wydawca - automatic release submission daemon -*- c -*- Copyright (C) 2007, 2009, 2010 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 txtacc *pp_cmd_acc; static struct grecs_list *source_list; static struct grecs_list *tag_list; static int string_cmp (const void *elt1, const void *elt2) { return strcmp ((const char *)elt1, (const char *)elt2); } int selected_spools () { return (source_list != NULL || tag_list != NULL); } int enabled_spool_p (const struct spool *spool) { if (source_list || tag_list) return (source_list && grecs_list_locate (source_list, spool->source_dir)) || (tag_list && grecs_list_locate (tag_list, spool->tag)); return 1; } OPTIONS_BEGIN("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 = grecs_list_create (); tag_list->cmp = string_cmp; } grecs_list_append (tag_list, optarg); END OPTION(source,s,SOURCE-DIR, []) BEGIN if (!source_list) { source_list = grecs_list_create (); source_list->cmp = string_cmp; } grecs_list_append (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 grecs_preproc_add_include_dir (optarg); END OPTION(define,D,SYMBOL[=VALUE], []) BEGIN char *p; if (!pp_cmd_acc) pp_cmd_acc = txtacc_create (); txtacc_grow (pp_cmd_acc, " \"-D", 4); for (p = optarg; *p; p++) { if (*p == '\\' || *p == '"') txtacc_1grow (pp_cmd_acc, '\\'); txtacc_1grow (pp_cmd_acc, *p); } txtacc_1grow (pp_cmd_acc, '"'); END OPTION(preprocessor,,COMMAND, []) BEGIN grecs_preprocessor = optarg; END OPTION(no-preprocessor,,, []) BEGIN grecs_preprocessor = NULL; END GROUP(Debugging) OPTION(debug,d,, []) BEGIN debug_level++; END OPTION(dump-grammar-trace,,, []) BEGIN grecs_gram_trace (1); END OPTION(dump-lex-trace,,, []) BEGIN grecs_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_acc && grecs_preprocessor) { char *defs = txtacc_finish (pp_cmd_acc); char *cmd = xmalloc (strlen (grecs_preprocessor) + strlen (defs) + 1); strcpy (cmd, grecs_preprocessor); strcat (cmd, defs); grecs_preprocessor = cmd; txtacc_free (pp_cmd_acc); } }