enum { MEMORY, DISK } storage; /* Where cases are stored. */
enum { WRITE, READ } mode; /* Is writing or reading allowed? */
struct casereader *readers; /* List of our readers. */
- int being_destroyed; /* Does a destructive reader exist? */
+ bool being_destroyed; /* Does a destructive reader exist? */
bool ok; /* False after I/O error. */
/* Memory storage. */
struct casereader *next, *prev; /* Next, prev in casefile's list. */
struct casefile *cf; /* Our casefile. */
unsigned long case_idx; /* Case number of current case. */
- int destructive; /* Is this a destructive reader? */
+ bool destructive; /* Is this a destructive reader? */
/* Disk storage. */
int fd; /* File descriptor. */
return !cf->ok;
}
-/* Returns nonzero only if casefile CF is stored in memory (instead of on
- disk). */
-int
+/* Returns true only if casefile CF is stored in memory (instead of on
+ disk), false otherwise. */
+bool
casefile_in_core (const struct casefile *cf)
{
assert (cf != NULL);
/* Reads a copy of the next case from READER into C.
Caller is responsible for destroying C.
Returns true if successful, false at end of file. */
-int
+bool
casereader_read (struct casereader *reader, struct ccase *c)
{
assert (reader != NULL);
if (!reader->cf->ok || reader->case_idx >= reader->cf->case_cnt)
- return 0;
+ return false;
if (reader->cf->storage == MEMORY)
{
case_clone (c, &reader->cf->cases[block_idx][case_idx]);
reader->case_idx++;
- return 1;
+ return true;
}
else
{
if (reader->buffer_pos + reader->cf->value_cnt > reader->cf->buffer_size)
{
if (!fill_buffer (reader))
- return 0;
+ return false;
reader->buffer_pos = 0;
}
reader->case_idx++;
case_clone (c, &reader->c);
- return 1;
+ return true;
}
}
to the caller. Caller is responsible for destroying C.
Returns true if successful, false at end of file or on I/O
error. */
-int
+bool
casereader_read_xfer (struct casereader *reader, struct ccase *c)
{
assert (reader != NULL);
case_move (c, read_case);
reader->case_idx++;
- return 1;
+ return true;
}
}
static void
register_atexit (void)
{
- static int registered = 0;
+ static bool registered = false;
if (!registered)
{
- registered = 1;
+ registered = true;
atexit (exit_handler);
}
}
-
-
/* atexit() handler that closes and deletes our temporary
files. */
static void
void casefile_destroy (struct casefile *);
bool casefile_error (const struct casefile *);
-int casefile_in_core (const struct casefile *);
+bool casefile_in_core (const struct casefile *);
bool casefile_to_disk (const struct casefile *);
bool casefile_sleep (const struct casefile *);
struct casereader *casefile_get_destructive_reader (struct casefile *);
const struct casefile *casereader_get_casefile (const struct casereader *);
-int casereader_read (struct casereader *, struct ccase *);
-int casereader_read_xfer (struct casereader *, struct ccase *);
+bool casereader_read (struct casereader *, struct ccase *);
+bool casereader_read_xfer (struct casereader *, struct ccase *);
void casereader_destroy (struct casereader *);
unsigned long casereader_cnum(const struct casereader *);