/* command "setcirc" */ void com_scirc(wordlist *wl) { struct circ *p; int i, j = 0; char buf[BSIZE_SP]; if (ft_circuits == NULL) { fprintf(cp_err, "Error: there aren't any circuits loaded.\n"); return; } if (wl == NULL) { fprintf(cp_out, "\tType the number of the desired circuit:\n\n"); for (p = ft_circuits; p; p = p->ci_next) { if (ft_curckt == p) fprintf(cp_out, "Current"); fprintf(cp_out, "\t%d\t%s\n", ++j, p->ci_name); } fprintf(cp_out, "? "); (void) fflush(cp_out); (void) fgets(buf, BSIZE_SP, cp_in); clearerr(cp_in); if ((sscanf(buf, " %d ", &i) != 1) || (i < 0) || (i > j)) return; for (p = ft_circuits; --i > 0; p = p->ci_next) ; } else { for (p = ft_circuits; p; p = p->ci_next) j++; p = NULL; if ((sscanf(wl->wl_word, " %d ", &i) != 1) || (i < 0) || (i > j)) ; else for (p = ft_circuits; --i > 0; p = p->ci_next) ; /* for (p = ft_circuits; p; p = p->ci_next) * if (ciprefix(wl->wl_word, p->ci_name)) * break; */ if (p == NULL) { fprintf(cp_err, "Warning: no such circuit \"%s\"\n", wl->wl_word); return; } fprintf(cp_out, "\t%s\n", p->ci_name); } if (ft_curckt) { /* Actually this can't be FALSE */ ft_curckt->ci_devices = cp_kwswitch(CT_DEVNAMES, p->ci_devices); ft_curckt->ci_nodes = cp_kwswitch(CT_NODENAMES, p->ci_nodes); } ft_curckt = p; /* get the model table for the current circuit, store it in the global variable modtab */ modtab = ft_curckt->ci_modtab; /* get the database for save, iplot, stop */ dbs = ft_curckt->ci_dbs; }
void plot_add(struct plot *pl) { struct dvec *v; struct plot *tp; char *s, buf[BSIZE_SP]; fprintf(cp_out, "Title: %s\nName: %s\nDate: %s\n\n", pl->pl_title, pl->pl_name, pl->pl_date); if (plot_cur) plot_cur->pl_ccom = cp_kwswitch(CT_VECTOR, pl->pl_ccom); for (v = pl->pl_dvecs; v; v = v->v_next) cp_addkword(CT_VECTOR, v->v_name); cp_addkword(CT_VECTOR, "all"); if ((s = ft_plotabbrev(pl->pl_name)) == NULL) s = "unknown"; do { (void) sprintf(buf, "%s%d", s, plot_num); for (tp = plot_list; tp; tp = tp->pl_next) if (cieq(tp->pl_typename, buf)) { plot_num++; break; } } while (tp); pl->pl_typename = copy(buf); plot_new(pl); cp_addkword(CT_PLOT, buf); pl->pl_ccom = cp_kwswitch(CT_VECTOR, NULL); plot_setcur(pl->pl_typename); }
struct plot * plot_alloc(char *name) { struct plot *pl = alloc(struct plot), *tp; char *s; struct ccom *ccom; char buf[BSIZE_SP]; ZERO(pl, struct plot); if ((s = ft_plotabbrev(name)) == NULL) s = "unknown"; do { (void) sprintf(buf, "%s%d", s, plot_num); for (tp = plot_list; tp; tp = tp->pl_next) if (cieq(tp->pl_typename, buf)) { plot_num++; break; } } while (tp); pl->pl_typename = copy(buf); cp_addkword(CT_PLOT, buf); /* va: create a new, empty keyword tree for class CT_VECTOR, s=old tree */ ccom = cp_kwswitch(CT_VECTOR, NULL); cp_addkword(CT_VECTOR, "all"); pl->pl_ccom = cp_kwswitch(CT_VECTOR, ccom); /* va: keyword tree is old tree again, new tree is linked to pl->pl_ccom */ return (pl); }