X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fchart.c;h=e324901cc4df1d445f3fc8c7a4b64296bca55bca;hb=400eaca1f378c40dced767bdc14a395dff220b8d;hp=a70862982b888e30e9c10955da06d34b6295f4d6;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp-builds.git diff --git a/src/output/chart.c b/src/output/chart.c index a7086298..e324901c 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) { @@ -73,6 +83,9 @@ chart_create(void) chart->legend_left = 810; chart->legend_right = 1000; chart->font_size = 0; + chart->in_path = false; + chart->dataset = NULL; + chart->n_datasets = 0; strcpy(chart->fill_colour,"red"); /* Get default font size */ @@ -90,6 +103,7 @@ chart_create(void) void chart_submit(struct chart *chart) { + int i; struct som_entity s; struct outp_driver *d; @@ -114,6 +128,41 @@ chart_submit(struct chart *chart) d = outp_drivers (NULL); d->class->finalise_chart(d, chart); + + for (i = 0 ; i < chart->n_datasets; ++i) + free (chart->dataset[i]); + free (chart->dataset); + 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); +}