1 /* PSPP - computes sample statistics.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 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, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "scratch-reader.h"
25 #include "dictionary.h"
26 #include "file-handle-def.h"
27 #include "scratch-handle.h"
28 #include <data/case.h>
29 #include <data/casereader.h>
30 #include <libpspp/message.h>
35 #define _(msgid) gettext (msgid)
37 /* Opens FH, which must have referent type FH_REF_SCRATCH, and
38 returns a scratch_reader for it, or a null pointer on
39 failure. Stores the dictionary for the scratch file into
42 scratch_reader_open (struct file_handle *fh, struct dictionary **dict)
44 struct scratch_handle *sh;
46 if (!fh_open (fh, FH_REF_SCRATCH, "scratch file", "rs"))
49 sh = fh_get_scratch_handle (fh);
50 if (sh == NULL || sh->casereader == NULL)
52 msg (SE, _("Scratch file handle %s has not yet been written, "
53 "using SAVE or another procedure, so it cannot yet "
54 "be used for reading."),
59 *dict = dict_clone (sh->dictionary);
60 return casereader_clone (sh->casereader);