+static void print_binary_flush_records (struct print_trns *,
+ struct string *line, int target_record,
+ bool *eject, int *record);
+
+/* Performs the transformation inside print_trns T on case C. */
+static int
+print_binary_trns_proc (void *trns_, struct ccase **c,
+ casenumber case_num UNUSED)
+{
+ struct print_trns *trns = trns_;
+ bool eject = trns->eject;
+ char encoded_space = recode_byte (trns->encoding, C_ENCODING, ' ');
+ int record = 1;
+ struct prt_out_spec *spec;
+ struct string line;
+
+ ds_init_empty (&line);
+ ds_put_byte (&line, ' ');
+ ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
+ {
+ print_binary_flush_records (trns, &line, spec->record, &eject, &record);
+
+ ds_set_length (&line, spec->first_column, encoded_space);
+ if (spec->type == PRT_VAR)
+ {
+ const union value *input = case_data (*c, spec->var);
+ if (!spec->sysmis_as_spaces || input->f != SYSMIS)
+ data_out_recode (input, var_get_encoding (spec->var),
+ &spec->format, &line, trns->encoding);
+ else
+ ds_put_byte_multiple (&line, encoded_space, spec->format.w);
+ if (spec->add_space)
+ ds_put_byte (&line, encoded_space);
+ }
+ else
+ {
+ ds_put_substring (&line, ds_ss (&spec->string));
+ if (0 != strcmp (trns->encoding, UTF8))
+ {
+ size_t length = ds_length (&spec->string);
+ char *data = ss_data (ds_tail (&line, length));
+ char *s = recode_string (trns->encoding, UTF8, data, length);
+ memcpy (data, s, length);
+ free (s);
+ }
+ }
+ }
+ print_binary_flush_records (trns, &line, trns->record_cnt + 1,
+ &eject, &record);
+ ds_destroy (&line);
+
+ if (trns->writer != NULL && dfm_write_error (trns->writer))
+ return TRNS_ERROR;
+ return TRNS_CONTINUE;
+}
+
+/* Advance from *RECORD to TARGET_RECORD, outputting records
+ along the way. If *EJECT is true, then the first record
+ output is preceded by ejecting the page (and *EJECT is set
+ false). */
+static void
+print_binary_flush_records (struct print_trns *trns, struct string *line,
+ int target_record, bool *eject, int *record)
+{
+ for (; target_record > *record; (*record)++)
+ {
+ char *s = ds_cstr (line);
+ size_t length = ds_length (line);
+ char leader = ' ';
+
+ if (*eject)
+ {
+ *eject = false;
+ leader = '1';
+ }
+ s[0] = recode_byte (trns->encoding, C_ENCODING, leader);
+
+ if (!trns->include_prefix)
+ {
+ s++;
+ length--;
+ }
+ dfm_put_record (trns->writer, s, length);
+
+ ds_truncate (line, 1);
+ }
+}
+\f