1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2008, 2010 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "source-init-opts.h"
25 #include "data/file-name.h"
26 #include "data/por-file-reader.h"
27 #include "data/settings.h"
28 #include "data/sys-file-reader.h"
29 #include "language/syntax-file.h"
30 #include "language/syntax-string-source.h"
31 #include "libpspp/assertion.h"
32 #include "libpspp/argv-parser.h"
33 #include "libpspp/getl.h"
34 #include "libpspp/llx.h"
35 #include "libpspp/message.h"
36 #include "ui/syntax-gen.h"
39 #include "gl/xalloc.h"
42 #define _(msgid) gettext (msgid)
43 #define N_(msgid) msgid
55 static const struct argv_option source_init_options[N_SOURCE_INIT_OPTIONS] =
57 {"algorithm", 'a', required_argument, OPT_ALGORITHM},
58 {"include", 'I', required_argument, OPT_INCLUDE},
59 {"no-include", 0, no_argument, OPT_NO_INCLUDE},
60 {"safer", 's', no_argument, OPT_SAFER},
61 {"syntax", 'x', required_argument, OPT_SYNTAX},
65 source_init_option_callback (int id, void *ss_)
67 struct source_stream *ss = ss_;
72 if (!strcmp (optarg, "compatible"))
73 settings_set_algorithm (COMPATIBLE);
74 else if (!strcmp (optarg, "enhanced"))
75 settings_set_algorithm (ENHANCED);
77 /* TRANSLATORS: Leave the words `compatible' and `enhanced' in their
80 _("Algorithm must be either `compatible' or `enhanced'."));
84 if (!strcmp (optarg, "-"))
85 getl_clear_include_path (ss);
87 getl_add_include_dir (ss, optarg);
91 getl_clear_include_path (ss);
95 settings_set_safer_mode ();
99 if (!strcmp (optarg, "compatible") )
100 settings_set_syntax (COMPATIBLE);
101 else if (!strcmp (optarg, "enhanced"))
102 settings_set_syntax (ENHANCED);
104 /* TRANSLATORS: Leave the words `compatible' and `enhanced' in their
107 _("Syntax must be either `compatible' or `enhanced'."));
116 source_init_register_argv_parser (struct argv_parser *ap,
117 struct source_stream *ss)
119 argv_parser_add_options (ap, source_init_options, N_SOURCE_INIT_OPTIONS,
120 source_init_option_callback, ss);