int gretl_bundle_write_to_file (gretl_bundle *b, const char *fname, int to_dotdir) { char fullname[FILENAME_MAX]; FILE *fp; int err = 0; if (to_dotdir) { build_path(fullname, gretl_dotdir(), fname, NULL); } else { strcpy(fullname, fname); gretl_maybe_switch_dir(fullname); } fp = gretl_fopen(fullname, "wb"); if (fp == NULL) { err = E_FOPEN; } else { gretl_xml_header(fp); gretl_bundle_serialize(b, "temp", fp); } return err; }
static int print_graph_page_direct (const char *fname, gretlopt opt) { char thisdir[MAXLEN]; char *latex_orig = NULL; int err = 0; if (gpage.ngraphs == 0) { gpage_errmsg(_("The graph page is empty"), 1); return 1; } if (getcwd(thisdir, MAXLEN - 1) == NULL) { *thisdir = '\0'; } gpage.mono = (opt & OPT_M) ? 1 : 0; gretl_chdir(get_session_dirname()); gpage_filenames_init(NULL); if (has_suffix(fname, ".pdf")) { gpage.term = GP_TERM_PDF; if (!get_tex_use_pdf()) { latex_orig = gpage_switch_compiler(gpage.term); } } else { gpage.term = GP_TERM_EPS; if (get_tex_use_pdf()) { latex_orig = gpage_switch_compiler(gpage.term); } } /* write the LaTeX driver file */ err = make_graphpage_tex(); if (!err) { /* transform individual plot files and compile using gnuplot */ err = make_gp_output(); } if (!err) { err = latex_compile_graph_page(); } if (!err) { char *output; if (gpage.term == GP_TERM_PDF) { output = gpage_fname(".pdf", 0); } else { output = gpage_fname(".ps", 0); } if (*thisdir != '\0') { /* come back out of dotdir */ chdir(thisdir); } fname = gretl_maybe_switch_dir(fname); err = gretl_copy_file(output, fname); if (!err) { fprintf(stderr, "graphpg: wrote %s\n", fname); } remove(output); } gpage_revert_compiler(latex_orig); gpage_cleanup(); return err; }