- struct outp_driver *d;
-
- for (d = outp_drivers (NULL); d; d = outp_drivers (d))
- if (d->class->output_chart != NULL)
- d->class->output_chart (d, chart);
-
- chart_unref (chart);
-}
-
-bool
-chart_create_file (const char *type, const char *file_name_tmpl, int number,
- plPlotterParams *params, char **file_namep, plPlotter **lpp)
-{
- char *file_name = NULL;
- FILE *fp = NULL;
- int number_pos;
- plPlotter *lp;
-
- number_pos = strchr (file_name_tmpl, '#') - file_name_tmpl;
- file_name = xasprintf ("%.*s%d%s", number_pos, file_name_tmpl,
- number, file_name_tmpl + number_pos + 1);
-
- fp = fopen (file_name, "wb");
- if (fp == NULL)
- {
- error (0, errno, _("creating \"%s\""), file_name);
- goto error;
- }
-
- if (params != NULL)
- lp = pl_newpl_r (type, 0, fp, stderr, params);
- else
- {
- params = pl_newplparams ();
- lp = pl_newpl_r (type, 0, fp, stderr, params);
- pl_deleteplparams (params);
- }
- if (lp == NULL)
- goto error;
-
- *file_namep = file_name;
- *lpp = lp;
- return true;
-
-error:
- if (fp != NULL)
- {
- fclose (fp);
- if (file_name != NULL)
- unlink (file_name);
- }
- free (file_name);
- *file_namep = NULL;
- *lpp = NULL;
- return false;