예제 #1
0
// CITIfile to Qucs conversion.
int citi2qucs (struct actionset_t * action, char * infile, char * outfile) {
  int ret = 0;
  citi_init ();
  if ((citi_in = open_file (infile, "r")) == NULL) {
    ret = -1;
  } else if (citi_parse () != 0) {
    ret = -1;
  } else if (citi_check () != 0) {
    ret = -1;
  }
  citi_lex_destroy ();
  if (citi_in)
    fclose (citi_in);
  if (ret) {
    citi_destroy ();
    return -1;
  }

  if (!strcmp (action->out, "qucsdata")) {
    citi_result->setFile (outfile);
    qucsdata_producer (citi_result);
  }
  citi_destroy ();
  return 0;
}
예제 #2
0
파일: dataset.cpp 프로젝트: FoxMarts/qucs
/* The function read a full dataset from the given CITIfile and
   returns it.  On failure the function emits appropriate error
   messages and returns NULL. */
dataset * dataset::load_citi (const char * file) {
  FILE * f;
  if ((f = fopen (file, "r")) == NULL) {
    logprint (LOG_ERROR, "error loading `%s': %s\n", file, strerror (errno));
    return NULL;
  }
  citi_in = f;
  citi_restart (citi_in);
  if (citi_parse () != 0) {
    fclose (f);
    return NULL;
  }
  if (citi_check () != 0) {
    fclose (f);
    return NULL;
  }
  fclose (f);
  citi_lex_destroy ();
  citi_result->setFile (file);
  return citi_result;
}
예제 #3
0
// Destroys data used by the CITIfile parser.
void citi_finalize (void) {
  struct citi_package_t * p, * pn;
  /* go through all packages */
  for (p = citi_root; p != NULL; p = pn) {
    struct citi_header_t * h, * hn;
    /* go through each header */
    for (h = p->head; h != NULL; h = hn) {
      if (h->package) free (h->package);
      if (h->var) free (h->var);
      if (h->type) free (h->type);
      hn = h->next;
      free (h);
    }
    vector * v, * vn;
    /* go through each vector */
    for (v = p->data; v != NULL; v = vn) {
      vn = (vector *) v->getNext ();
      delete v;
    }
    pn = p->next;
    free (p);
  }
  citi_lex_destroy ();
}