-/* Seeks CTF's underlying file to the start of `union value'
- VALUE_IDX within case CASE_IDX.
- Returns true if the seek is successful and CTF is not
- otherwise tainted, false otherwise. */
-static bool
-do_seek (const struct case_tmpfile *ctf_,
- casenumber case_idx, size_t value_idx)
-{
- struct case_tmpfile *ctf = (struct case_tmpfile *) ctf_;
-
- if (!case_tmpfile_error (ctf))
- {
- off_t value_ofs = value_idx + (off_t) ctf->value_cnt * case_idx;
- off_t byte_ofs = sizeof (union value) * value_ofs;
-
- if (ctf->position == byte_ofs)
- return true;
- else if (fseeko (ctf->file, byte_ofs, SEEK_SET) == 0)
- {
- ctf->position = byte_ofs;
- return true;
- }
- else
- {
- error (0, errno, _("seeking in temporary file"));
- case_tmpfile_force_error (ctf);
- }
- }
-
- return false;
-}
-
-/* Reads BYTES bytes from CTF's underlying file into BUFFER.
- CTF must not be tainted upon entry into this function.
- Returns true if successful, false upon an I/O error (in which
- case CTF is marked tainted). */
-static bool
-do_read (const struct case_tmpfile *ctf_, size_t bytes, void *buffer)
-{
- struct case_tmpfile *ctf = (struct case_tmpfile *) ctf_;
-
- assert (!case_tmpfile_error (ctf));
- if (fread (buffer, bytes, 1, ctf->file) != 1)
- {
- case_tmpfile_force_error (ctf);
- if (ferror (ctf->file))
- error (0, errno, _("reading temporary file"));
- else if (feof (ctf->file))
- error (0, 0, _("unexpected end of file reading temporary file"));
- else
- NOT_REACHED ();
- return false;
- }
- ctf->position += bytes;
- return true;
-}
-
-/* Writes BYTES bytes from BUFFER into CTF's underlying file.
- CTF must not be tainted upon entry into this function.
- Returns true if successful, false upon an I/O error (in which
- case CTF is marked tainted). */
-static bool
-do_write (struct case_tmpfile *ctf, size_t bytes, const void *buffer)
-{
- assert (!case_tmpfile_error (ctf));
- if (fwrite (buffer, bytes, 1, ctf->file) != 1)
- {
- case_tmpfile_force_error (ctf);
- error (0, errno, _("writing to temporary file"));
- return false;
- }
- ctf->position += bytes;
- return true;
-}
-
-/* Reads VALUE_CNT values into VALUES, from the case numbered
- CASE_IDX starting START_VALUE values into that case.
- Returns true if successful, false if CTF is tainted or an I/O
- error occurs during the operation.