+dataset_name (const struct dataset *ds)
+{
+ return ds->name;
+}
+
+void
+dataset_set_name (struct dataset *ds, const char *name)
+{
+ struct session *session = ds->session;
+ bool active = false;
+
+ if (session != NULL)
+ {
+ active = session_active_dataset (session) == ds;
+ if (active)
+ session_set_active_dataset (session, NULL);
+ dataset_set_session (ds, NULL);
+ }
+
+ free (ds->name);
+ ds->name = xstrdup (name);
+
+ if (session != NULL)
+ {
+ dataset_set_session (ds, session);
+ if (active)
+ session_set_active_dataset (session, ds);
+ }
+}
+
+struct session *
+dataset_session (const struct dataset *ds)
+{
+ return ds->session;
+}
+
+void
+dataset_set_session (struct dataset *ds, struct session *session)
+{
+ if (session != ds->session)
+ {
+ if (ds->session != NULL)
+ session_remove_dataset (ds->session, ds);
+ if (session != NULL)
+ session_add_dataset (session, ds);
+ }
+}
+
+/* Returns the dictionary within DS. This is always nonnull, although it
+ might not contain any variables. */
+struct dictionary *
+dataset_dict (const struct dataset *ds)
+{
+ return ds->dict;
+}
+
+/* Replaces DS's dictionary by DICT, discarding any source and
+ transformations. */
+void
+dataset_set_dict (struct dataset *ds, struct dictionary *dict)
+{
+ assert (ds->proc_state == PROC_COMMITTED);
+ assert (ds->dict != dict);
+
+ dataset_clear (ds);
+
+ dict_destroy (ds->dict);
+ ds->dict = dict;
+ dict_set_change_callback (ds->dict, dict_callback, ds);
+}
+
+/* Returns the casereader that will be read when a procedure is executed on
+ DS. This can be NULL if none has been set up yet. */
+const struct casereader *
+dataset_source (const struct dataset *ds)
+{
+ return ds->source;
+}
+
+/* Returns true if DS has a data source, false otherwise. */
+bool
+dataset_has_source (const struct dataset *ds)
+{
+ return dataset_source (ds) != NULL;
+}
+
+/* Replaces the active dataset's data by READER. READER's cases must have an
+ appropriate format for DS's dictionary. */
+bool
+dataset_set_source (struct dataset *ds, struct casereader *reader)
+{
+ casereader_destroy (ds->source);
+ ds->source = reader;
+
+ caseinit_clear (ds->caseinit);
+ caseinit_mark_as_preinited (ds->caseinit, ds->dict);
+
+ return reader == NULL || !casereader_error (reader);
+}
+
+/* Returns the data source from DS and removes it from DS. Returns a null
+ pointer if DS has no data source. */
+struct casereader *
+dataset_steal_source (struct dataset *ds)
+{
+ struct casereader *reader = ds->source;
+ ds->source = NULL;
+
+ return reader;
+}
+
+/* Returns a number unique to DS. It can be used to distinguish one dataset
+ from any other within a given program run, even datasets that do not exist
+ at the same time. */
+unsigned int
+dataset_seqno (const struct dataset *ds)