X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fchart.c;h=49819e9fe03cc4073242ae97d05b77365c7e78a2;hb=b41d1740e6755ac0512f92fb8578e9d8baf3a88b;hp=a70862982b888e30e9c10955da06d34b6295f4d6;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp diff --git a/src/output/chart.c b/src/output/chart.c index a70862982b..49819e9fe0 100644 --- a/src/output/chart.c +++ b/src/output/chart.c @@ -15,20 +15,29 @@ along with this program. If not, see . */ #include + +#include + +#include +#include +#include +#include +#include #include #include -#include -#include #include -#include -#include -#include -#include "chart.h" +#include + #include -#include -#include "manager.h" -#include "output.h" +#include +#include + +#include "error.h" +#include "xalloc.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) extern struct som_table_class tab_table_class; @@ -43,6 +52,7 @@ chart_create(void) return NULL; chart = xmalloc (sizeof *chart); + chart->lp = NULL; d->class->initialise_chart(d, chart); if (!chart->lp) { @@ -117,3 +127,33 @@ chart_submit(struct chart *chart) free(chart); } +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); +}