1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2012 Free Software Foundation, Inc.
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/>. */
22 #if HAVE_FPU_CONTROL_H
23 #include <fpu_control.h>
33 #include "data/dataset.h"
34 #include "data/dictionary.h"
35 #include "data/file-handle-def.h"
36 #include "data/file-name.h"
37 #include "data/session.h"
38 #include "data/settings.h"
39 #include "data/variable.h"
40 #include "gsl/gsl_errno.h"
41 #include "language/command.h"
42 #include "language/lexer/lexer.h"
43 #include "language/lexer/include-path.h"
44 #include "libpspp/argv-parser.h"
45 #include "libpspp/compiler.h"
46 #include "libpspp/i18n.h"
47 #include "libpspp/message.h"
48 #include "libpspp/version.h"
49 #include "math/random.h"
50 #include "output/driver.h"
51 #include "output/message-item.h"
52 #include "ui/source-init-opts.h"
54 #include "gl/fatal-signal.h"
55 #include "gl/progname.h"
56 #include "gl/relocatable.h"
59 #define _(msgid) gettext (msgid)
61 static void bug_handler(int sig);
62 static void fpu_init (void);
64 /* Program entry point. */
66 main (int argc, char **argv)
70 set_program_name (argv[0]);
72 signal (SIGABRT, bug_handler);
73 signal (SIGSEGV, bug_handler);
74 signal (SIGFPE, bug_handler);
78 gsl_set_error_handler_off ();
84 //msg_set_handler (output_msg, lexer);
86 while (fgets (s, sizeof s, stdin))
88 struct pspp_proc_request *request;
89 struct pxd_object *object;
93 if (sscanf (s, PXD_ID_FMT"%n", PXD_ID_SCAN_ARGS (&id), &n) <= 0 || n < 0)
95 printf ("bad input format\n");
100 object = pxd_fetch (pxd, &id);
103 printf (PXD_ID_FMT": object not found\n", PXD_ID_ARGS (&id));
108 request = pspp_proc_request_load (object, pxd);
109 pxd_object_unref (object);
112 printf (PXD_ID_FMT": bad request\n", PXD_ID_FMT (&id));
117 reply = pspp_proc_request_execute (request);
120 printf (PXD_ID_FMT": could not execute request\n", PXD_ID_FMT (&id));
125 object = pspp_proc_reply_save (reply, pxd);
126 pspp_proc_reply_destroy (reply);
129 printf (PXD_ID_FMT": could not save reply\n", PXD_ID_FMT (&id));
134 printf (PXD_ID_FMT"\n", PXD_ID_FMT (pxd_object_id (object)));
136 pxd_object_unref (object);
138 /* XXX what keeps the reply from getting garbage collected? */
152 #if HAVE_FEHOLDEXCEPT
155 #elif HAVE___SETFPUCW && defined(_FPU_IEEE)
156 __setfpucw (_FPU_IEEE);
162 /* If a segfault happens, issue a message to that effect and halt */
166 /* Reset SIG to its default handling so that if it happens again we won't
168 signal (sig, SIG_DFL);
173 request_bug_report("Assertion Failure/Abort");
176 request_bug_report("Floating Point Exception");
179 request_bug_report("Segmentation Violation");
182 request_bug_report("Unknown");
186 /* Re-raise the signal so that we terminate with the correct status. */