/* The function read a full dataset from the given MDL file and returns it. On failure the function emits appropriate error messages and returns NULL. */ dataset * dataset::load_mdl (const char * file) { FILE * f; if ((f = fopen (file, "r")) == NULL) { logprint (LOG_ERROR, "error loading `%s': %s\n", file, strerror (errno)); return NULL; } mdl_in = f; mdl_restart (mdl_in); if (mdl_parse () != 0) { fclose (f); return NULL; } if (mdl_check () != 0) { fclose (f); return NULL; } fclose (f); mdl_lex_destroy (); if (mdl_result) mdl_result->setFile (file); return mdl_result; }
// MDL to Qucs conversion. int mdl2qucs (struct actionset_t * action, char * infile, char * outfile) { int ret = 0; mdl_init (); if ((mdl_in = open_file (infile, "r")) == NULL) { ret = -1; } else if (mdl_parse () != 0) { ret = -1; } else if (mdl_check () != 0) { ret = -1; } mdl_lex_destroy (); if (mdl_in) fclose (mdl_in); if (ret) { mdl_destroy (); return -1; } if (!strcmp (action->out, "qucsdata")) { mdl_result->setFile (outfile); qucsdata_producer (mdl_result); } mdl_destroy (); return 0; }