+void
+chart_init_separate (struct chart *ch, const char *type,
+ const char *file_name_tmpl, int number)
+{
+ FILE *fp;
+ int number_pos;
+
+ number_pos = strchr (file_name_tmpl, '#') - file_name_tmpl;
+ ch->file_name = xasprintf ("%.*s%d%s",
+ number_pos, file_name_tmpl,
+ number,
+ file_name_tmpl + number_pos + 1);
+ fp = fopen (ch->file_name, "wb");
+ if (fp == NULL)
+ {
+ error (0, errno, _("creating \"%s\""), ch->file_name);
+ free (ch->file_name);
+ ch->file_name = NULL;
+ return;
+ }
+
+ ch->pl_params = pl_newplparams ();
+ ch->lp = pl_newpl_r (type, 0, fp, stderr, ch->pl_params);
+}
+
+void
+chart_finalise_separate (struct chart *ch)
+{
+ free (ch->file_name);
+}