/* The function read a full dataset from the given ZVR file and returns it. On failure the function emits appropriate error messages and returns NULL. */ dataset * dataset::load_zvr (const char * file) { FILE * f; if ((f = fopen (file, "r")) == NULL) { logprint (LOG_ERROR, "error loading `%s': %s\n", file, strerror (errno)); return NULL; } zvr_in = f; zvr_restart (zvr_in); if (zvr_parse () != 0) { fclose (f); return NULL; } if (zvr_check () != 0) { fclose (f); return NULL; } fclose (f); zvr_lex_destroy (); if (zvr_result) zvr_result->setFile (file); return zvr_result; }
// ZVR to Qucs conversion. int zvr2qucs (struct actionset_t * action, char * infile, char * outfile) { int ret = 0; zvr_init (); if ((zvr_in = open_file (infile, "r")) == NULL) { ret = -1; } else if (zvr_parse () != 0) { ret = -1; } else if (zvr_check () != 0) { ret = -1; } zvr_lex_destroy (); if (zvr_in) fclose (zvr_in); if (ret) { zvr_destroy (); return -1; } if (!strcmp (action->out, "qucsdata")) { zvr_result->setFile (outfile); qucsdata_producer (zvr_result); } zvr_destroy (); return 0; }