📄 bspice.c
字号:
if (st == true) exit(EXIT_BAD); st = true; if (ft_servermode) { if (ft_curckt == NULL) { fprintf(cp_err, "Error: No circuit loaded!\n"); exit(EXIT_BAD); } } ft_dotsaves(); ft_dorun(ft_rawfile); ft_cktcoms(false); fprintf(stderr, "Warning: .plot, etc cards ignored (rawfile only).\n"); exit(EXIT_NORMAL);}/* Now some misc junk that we need to fake... */bool cp_nocc = true;bool cp_debug = false;int cp_maxhistlength;char cp_chars[128];bool ft_parsedb = false;/* ARGSUSED */ struct dvec *vec_fromplot(w, p) char *w; struct plot *p; { return (NULL); }void vec_new() {}void plot_new() {}void plot_setcur() {}void cp_pushcontrol() {}void cp_popcontrol() {}/* ARGSUSED */ char *cp_tildexpand(s) char *s; { return (s); }/* ARGSUSED */ void cp_addkword(class, word) int class; char *word; {}struct circ *ft_circuits, *ft_curckt;/* ARGSUSED */ struct plot *plot_alloc(name) char *name; { return (NULL); }struct plot *plot_cur = NULL;/* ARGSUSED */ char *cp_kwswitch(c, t) int c; char *t; { return (NULL); }/* ARGSUSED */ void plot_docoms(wl) wordlist *wl; {}/* ARGSUSED */ bool ft_bpcheck(r, i) struct plot *r; int i; { return (true); }/* ARGSUSED */ void cp_ccon(b) bool b; {}/* ARGSUSED */ void gr_iplot(pl) struct plot *pl; {}/* ARGSUSED */ void gr_end_iplot(pl) struct plot *pl; {}/* ARGSUSED */ void gr_pmsg(text, more) char *text; bool more; {}/* ARGSUSED */ int cp_evloop(string) char *string; { return (0); }/* ARGSUSED */ void gr_clean(intr) bool intr; {}void ft_trquery() {}void out_init() {}#ifndef LATTICE/* PC defines out_printf to printf since vsprintf doesn't exist *//* ARGSUSED */ /* VARARGS1 */ void out_printf(c) char *c; {}#endif/* ARGSUSED */ void out_send(s) char *s; {}char out_pbuf[1];/* ARGSUSED */ void ft_newcirc(ckt) struct circ *ckt; {}/* ARGSUSED */ struct dvec *vec_get(word) char *word; { return (NULL); }void cp_doquit() { exit(0); }/* ARGSUSED */ void cp_usrvars(v1, v2) struct variable **v1, **v2; { return; }/* ARGSUSED */ struct variable * cp_enqvar(word) char *word; { return (NULL); }/* ARGSUSED */ void cp_ccom(w, b, e) wordlist *w; char *b; bool e; { return; }/* ARGSUSED */ int cp_usrset(v, i) struct variable *v; bool i; {return (US_OK);}/* This is from breakpoint.c */struct dbcomm *dbs = NULL; /* export for iplot */static int debugnumber = 1;static voidsettrace(wl, what) wordlist *wl;{ struct dbcomm *d, *td; char *s; while (wl) { s = cp_unquote(wl->wl_word); d = alloc(dbcomm); d->db_number = debugnumber++; if (eq(s, "all")) { switch (what) { case VF_PRINT: d->db_type = DB_TRACEALL; break;/* case VF_PLOT: d->db_type = DB_IPLOTALL; break; */ case VF_ACCUM: d->db_type = DB_SAVEALL; break; }/* wrd_chtrace((char *) NULL, true, what); */ } else { switch (what) { case VF_PRINT: d->db_type = DB_TRACENODE; break;/* case VF_PLOT: d->db_type = DB_IPLOT; break; */ case VF_ACCUM: d->db_type = DB_SAVE; break; } d->db_nodename1 = copy(s);/* wrd_chtrace(s, true, what); */ } if (dbs) { for (td = dbs; td->db_next; td = td->db_next) ; td->db_next = d; } else dbs = d; wl = wl->wl_next; } return;}/* Save a vector. */voidcom_save(wl) wordlist *wl;{ settrace(wl, VF_ACCUM); return;}/* This is from dotcards.c -- we don't want to include the whole file. */static wordlist *gettoks();/* Extract all the .save cards... */voidft_dotsaves(){ wordlist *com, *wl = NULL; char *s; if (!ft_curckt) /* Shouldn't happen. */ return; for (com = ft_curckt->ci_commands; com; com = com->wl_next) { if (ciprefix(".save", com->wl_word)) { s = com->wl_word; (void) gettok(&s); wl = wl_append(wl, gettoks(s)); } }/* wrd_saves = wl; */ com_save(wl);/* fprintf(stderr, "error, .save card code is broken\n"); */ return;}/* This is also from dotcards.c. We should probably include the file. *//* Stripped down version. *//* Execute the .whatever cards found in the deck, after we are done running. * We'll be cheap and use cp_lexer to get the words... This should make us * spice-2 compatible. Is terse is true then there was a rawfile, so don't * print lots of junk. */voidft_cktcoms(terse) bool terse;{ wordlist *coms, *command; char *plottype, *s; struct dvec *v; static wordlist twl = { "col", NULL, NULL } ; int i; if (!ft_curckt) return; if (!ft_curckt->ci_commands) goto nocmds; coms = ft_curckt->ci_commands; cp_interactive = false;nocmds: /* Circuit name... */ fprintf(cp_out, "Circuit: %s\nDate: %s\n\n", ft_curckt->ci_name, datestring()); fprintf(cp_out, "\n");/* gtri - modify - 12/24/90 - wbk - if IPC enabled, do a listing */ if(g_ipc.enabled) { /* Print listings of input deck */ printf("\n\n****************** INPUT DECK **********************\n\n"); inp_list(stdout, ft_curckt->ci_origdeck, ft_curckt->ci_options, LS_DECK); printf("\n\n***************** EXPANDED DECK ********************\n\n"); inp_list(stdout, ft_curckt->ci_deck, ft_curckt->ci_options, LS_LOGICAL); printf("\n\n****************************************************\n\n"); } else { /* original code */ /* Listing if necessary... */ if (ft_listprint) inp_list(cp_out, ft_curckt->ci_deck, ft_curckt->ci_options, LS_DECK); }/* gtri - end - 12/24/90 */ /* And finally the accounting info. */ if (ft_acctprint) { static wordlist ww = { "everything", NULL, NULL } ; com_rusage(&ww); } else com_rusage((wordlist *) NULL); (void) putc('\n', cp_out); return;bad: fprintf(cp_err, "Internal Error: ft_cktcoms: bad commands\n"); return;}intft_getSaves(savesp) char ***savesp;{ return (0);}static wordlist *gettoks(s) char *s;{ char *t, *r, buf[64]; wordlist *wl = NULL, *end = NULL; bool iflag; while (t = gettok(&s)) { if (*t == '(' /* ) */) { /* This is a (upper, lower) thing -- ignore. */ continue; } else if (!index(t, '(' /*)*/ )) { if (end) { end->wl_next = alloc(wordlist); end->wl_next->wl_prev = end; end = end->wl_next; } else wl = end = alloc(wordlist); end->wl_word = copy(t); } else if (!index(t, ',')) { iflag = ((*t == 'i') || (*t == 'I')) ? true : false; while (*t != '(' /*)*/) t++; t++; for (r = t; *r && *r != /*(*/ ')'; r++) ; *r = '\0'; if (end) { end->wl_next = alloc(wordlist); end->wl_next->wl_prev = end; end = end->wl_next; } else wl = end = alloc(wordlist); if (iflag) { (void) sprintf(buf, "%s#branch", t); t = buf; } end->wl_word = copy(t); } else { /* The painful case... */ while (*t != '(' /*)*/) t++; t++; for (r = t; *r && *r != ','; r++) ; *r = '\0'; if (end) { end->wl_next = alloc(wordlist); end->wl_next->wl_prev = end; end = end->wl_next; } else wl = end = alloc(wordlist); end->wl_word = copy(t); t = r + 1; for (r = t; *r && *r != /*(*/ ')'; r++) ; *r = '\0'; if (end) { end->wl_next = alloc(wordlist); end->wl_next->wl_prev = end; end = end->wl_next; } else wl = end = alloc(wordlist); end->wl_word = copy(t); } } return (wl);}/* This is from options.c *//* Extract the .option cards from the deck... */struct line *inp_getopts(deck) struct line *deck;{ struct line *last = NULL, *opts = NULL, *dd, *next = NULL; for (dd = deck->li_next; dd; dd = next) { next = dd->li_next; if (ciprefix(".opt", dd->li_line)) { inp_casefix(dd->li_line); if (last) last->li_next = dd->li_next; else deck->li_next = dd->li_next; dd->li_next = opts; opts = dd; } else last = dd; } return (opts);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -