示例#1
0
// Touchstone to Qucs conversion.
int touch2qucs (struct actionset_t * action, char * infile, char * outfile) {
  int ret = 0;
  touchstone_init ();
  if ((touchstone_in = open_file (infile, "r")) == NULL) {
    ret = -1;
  } else if (touchstone_parse () != 0) {
    ret = -1;
  } else if (touchstone_check () != 0) {
    ret = -1;
  }
  touchstone_lex_destroy ();
  if (touchstone_in)
    fclose (touchstone_in);
  if (ret) {
    touchstone_destroy ();
    return -1;
  }

  if (!strcmp (action->out, "qucsdata")) {
    touchstone_result->setFile (outfile);
    qucsdata_producer (touchstone_result);
  }
  touchstone_destroy ();
  return 0;
}
示例#2
0
文件: dataset.cpp 项目: FoxMarts/qucs
/* This static function read a full dataset from the given touchstone
   file and returns it.  On failure the function emits appropriate
   error messages and returns NULL. */
dataset * dataset::load_touchstone (const char * file) {
  FILE * f;
  if ((f = fopen (file, "r")) == NULL) {
    logprint (LOG_ERROR, "error loading `%s': %s\n", file, strerror (errno));
    return NULL;
  }
  touchstone_in = f;
  touchstone_restart (touchstone_in);
  if (touchstone_parse () != 0) {
    fclose (f);
    return NULL;
  }
  if (touchstone_check () != 0) {
    fclose (f);
    return NULL;
  }
  fclose (f);
  touchstone_lex_destroy ();
  touchstone_result->setFile (file);
  return touchstone_result;
}