ngspice/src/frontend/misccoms.c

259 lines
7.4 KiB
C
Raw Normal View History

2000-04-27 22:03:57 +02:00
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
**********/
#include "ngspice.h"
#include "cpdefs.h"
#include "ftedefs.h"
* src/Makefile.am src/main.c src/sconvert.c src/analysis/cktdisto.c src/analysis/cktnoise.c src/analysis/noisean.c: Updates for the new header files. * src/maths/cmaths/cmath1.c src/maths/cmaths/cmath2.c src/maths/cmaths/cmath3.c src/maths/cmaths/cmath4.c: Updates for the new header files. * src/frontend/.cvsignore src/frontend/Makefile.am: Updates for the new files. * src/frontend/agraf.c src/frontend/aspice.c src/frontend/breakp.c src/frontend/breakp2.c src/frontend/circuits.c src/frontend/cpitf.c src/frontend/debugcom.c src/frontend/define.c src/frontend/diff.c src/frontend/dimens.c src/frontend/display.c src/frontend/doplot.c src/frontend/dotcards.c src/frontend/evaluate.c src/frontend/fourier.c src/frontend/graf.c src/frontend/grid.c src/frontend/inp.c src/frontend/inpcom.c src/frontend/interp.c src/frontend/linear.c src/frontend/misccoms.c src/frontend/misccoms.h src/frontend/miscvars.c src/frontend/mw_coms.c src/frontend/newcoms.c src/frontend/nutinp.c src/frontend/options.c src/frontend/outitf.c src/frontend/parse.c src/frontend/plotcurv.c src/frontend/points.c src/frontend/postcoms.c src/frontend/rawfile.c src/frontend/runcoms.c src/frontend/runcoms2.c src/frontend/shyu.c src/frontend/spec.c src/frontend/spiceif.c src/frontend/typesdef.c src/frontend/vectors.c src/frontend/where.c src/frontend/postcoms.c: Updates for the new header files. Some commands have moved into the new files below. * src/frontend/README src/frontend/com_compose.c src/frontend/com_compose.h src/frontend/com_display.c src/frontend/com_display.h src/frontend/com_let.c src/frontend/com_let.h src/frontend/com_setscale.c src/frontend/com_setscale.h src/frontend/commands.c src/frontend/commands.h src/frontend/completion.h src/frontend/streams.h src/frontend/testcommands.c: Separation into different com_* commands. This is a start. The rest of the subdirectory needs doing. * src/include/complex.h src/include/cpdefs.h src/include/cpextern.h src/include/cpstd.h src/include/fteconst.h src/include/ftedata.h src/include/ftedev.h src/include/fteext.h src/include/ftegraph.h src/include/fteparse.h src/include/dvec.h src/include/grid.h src/include/plot.h src/include/pnode.h src/include/sim.h src/include/variable.h src/include/wordlist.h src/include/bool.h: Separation of header files into smaller pieces. This limits recompilation to only the affected source files. The original header files have a warning message embedded to flag obsoleted use. * src/frontend/compose.c src/frontend/compose.h src/frontend/nutctab.c src/frontend/nutctab.h src/frontend/plot5.c src/frontend/plot5.h src/frontend/spcmdtab.c src/frontend/x11.c src/frontend/x11.h src/frontend/xgraph.c src/frontend/xgraph.h: Moved these files into src/frontend/plotting subdirectory. * src/frontend/plotting/.cvsignore src/frontend/plotting/Makefile.am src/frontend/plotting/plot5.c src/frontend/plotting/plot5.h src/frontend/plotting/plotting.c src/frontend/plotting/plotting.h src/frontend/plotting/pvec.c src/frontend/plotting/pvec.h src/frontend/plotting/x11.c src/frontend/plotting/x11.h src/frontend/plotting/xgraph.c src/frontend/plotting/xgraph.h: The new libplotting library with automake and CVS infrastructure.
2000-05-06 16:12:51 +02:00
#include "dvec.h"
2000-04-27 22:03:57 +02:00
#include "ftehelp.h"
#include "hlpdefs.h"
#include "misccoms.h"
src/Makefile.am src/help.c src/main.c src/circuit/Makefile.am src/circuit/ifnewuid.c src/frontend/Makefile.am src/frontend/aspice.c src/frontend/circuits.h src/frontend/com_display.c src/frontend/com_hardcopy.c src/frontend/commands.c src/frontend/commands.h src/frontend/cpitf.c src/frontend/debugcom.c src/frontend/device.c src/frontend/diff.c src/frontend/display.c src/frontend/dotcards.c src/frontend/fourier.c src/frontend/inp.c src/frontend/inpcom.c src/frontend/linear.c src/frontend/misccoms.c src/frontend/mw_coms.c src/frontend/nutinp.c src/frontend/options.c src/frontend/outitf.c src/frontend/parse.c src/frontend/postcoms.c src/frontend/postsc.c src/frontend/rawfile.c src/frontend/resource.c src/frontend/runcoms.c src/frontend/runcoms2.c src/frontend/shyu.c src/frontend/spec.c src/frontend/spiceif.c src/frontend/subckt.c src/frontend/vectors.c src/frontend/where.c src/frontend/plotting/Makefile.am src/frontend/plotting/agraf.c src/frontend/plotting/graf.c src/frontend/plotting/plotcurv.c src/frontend/plotting/plotit.c src/frontend/plotting/x11.c src/frontend/plotting/xgraph.c src/include/Makefile.am src/maths/cmaths/cmath4.c src/misc/terminal.c src/misc/terminal.h src/parser/cshpar.c src/parser/front.c src/parser/front.h src/parser/history.c src/parser/history.h src/parser/modify.c src/parser/var2.c src/parser/var2.h src/parser/variable.c: Refactoring of frontend code. * src/include/ftehelp.h src/include/variable.h: Moved into frontend directory. * src/include/cpdefs.h src/include/cpextern.h src/include/ftedefs.h src/include/plot.h: Updates.
2000-06-27 18:09:02 +02:00
#include "circuits.h"
#include "variable.h"
#include "plotting/graf.h"
2000-04-27 22:03:57 +02:00
#ifdef HAVE_GNUREADLINE
#include <readline/readline.h>
#include <readline/history.h>
extern char history_file[];
#endif /* HAVE_GNUREADLINE */
#ifdef HAVE_BSDEDITLINE
/* SJB added edit line support 2005-05-05 */
#include <editline/readline.h>
extern char history_file[];
#endif /* HAVE_BSDEDITLINE */
2007-05-01 05:40:17 +02:00
extern IFsimulator SIMinfo;
src/Makefile.am src/help.c src/main.c src/circuit/Makefile.am src/circuit/ifnewuid.c src/frontend/Makefile.am src/frontend/aspice.c src/frontend/circuits.h src/frontend/com_display.c src/frontend/com_hardcopy.c src/frontend/commands.c src/frontend/commands.h src/frontend/cpitf.c src/frontend/debugcom.c src/frontend/device.c src/frontend/diff.c src/frontend/display.c src/frontend/dotcards.c src/frontend/fourier.c src/frontend/inp.c src/frontend/inpcom.c src/frontend/linear.c src/frontend/misccoms.c src/frontend/mw_coms.c src/frontend/nutinp.c src/frontend/options.c src/frontend/outitf.c src/frontend/parse.c src/frontend/postcoms.c src/frontend/postsc.c src/frontend/rawfile.c src/frontend/resource.c src/frontend/runcoms.c src/frontend/runcoms2.c src/frontend/shyu.c src/frontend/spec.c src/frontend/spiceif.c src/frontend/subckt.c src/frontend/vectors.c src/frontend/where.c src/frontend/plotting/Makefile.am src/frontend/plotting/agraf.c src/frontend/plotting/graf.c src/frontend/plotting/plotcurv.c src/frontend/plotting/plotit.c src/frontend/plotting/x11.c src/frontend/plotting/xgraph.c src/include/Makefile.am src/maths/cmaths/cmath4.c src/misc/terminal.c src/misc/terminal.h src/parser/cshpar.c src/parser/front.c src/parser/front.h src/parser/history.c src/parser/history.h src/parser/modify.c src/parser/var2.c src/parser/var2.h src/parser/variable.c: Refactoring of frontend code. * src/include/ftehelp.h src/include/variable.h: Moved into frontend directory. * src/include/cpdefs.h src/include/cpextern.h src/include/ftedefs.h src/include/plot.h: Updates.
2000-06-27 18:09:02 +02:00
static void byemesg(void);
2000-04-27 22:03:57 +02:00
void
com_quit(wordlist *wl)
{
struct circ *cc;
struct plot *pl;
int ncc = 0, npl = 0;
char buf[64];
bool noask;
noask = cp_getvar("noaskquit", CP_BOOL, NULL);
2000-04-27 22:03:57 +02:00
gr_clean();
cp_ccon(FALSE);
if(wl)
if(wl->wl_word)
if(cieq(wl->wl_word,"noask"))
{
byemesg();
exit(EXIT_NORMAL);
}
2000-04-27 22:03:57 +02:00
/* Make sure the guy really wants to quit. */
if (!ft_nutmeg && !noask) {
for (cc = ft_circuits; cc; cc = cc->ci_next)
if (cc->ci_inprogress)
ncc++;
for (pl = plot_list; pl; pl = pl->pl_next)
if (!pl->pl_written && pl->pl_dvecs)
npl++;
if (ncc || npl) {
fprintf(cp_out, "Warning: ");
if (ncc) {
fprintf(cp_out,
"the following simulation%s still in progress:\n",
(ncc > 1) ? "s are" : " is");
for (cc = ft_circuits; cc; cc = cc->ci_next)
if (cc->ci_inprogress)
fprintf(cp_out, "\t%s\n",
cc->ci_name);
}
if (npl) {
if (ncc)
fprintf(cp_out, "and ");
fprintf(cp_out,
"the following plot%s been saved:\n",
(npl > 1) ? "s haven't" : " hasn't");
for (pl = plot_list; pl; pl = pl->pl_next)
if (!pl->pl_written && pl->pl_dvecs)
fprintf(cp_out, "%s\t%s, %s\n",
pl->pl_typename,
pl->pl_title,
pl->pl_name);
}
fprintf(cp_out,
"\nAre you sure you want to quit (yes)? ");
(void) fflush(cp_out);
2010-10-04 22:58:00 +02:00
if (!fgets(buf, sizeof(buf), stdin)) {
2000-04-27 22:03:57 +02:00
clearerr(stdin);
*buf = 'y';
}
if ((*buf == 'y') || (*buf == 'Y') || (*buf == '\n')) {
2007-05-01 05:40:17 +02:00
#ifdef EXPERIMENTAL_CODE
/* Destroy CKT when quit. Add by Gong Ding, gdiso@ustc.edu */
for (cc = ft_circuits; cc; cc = cc->ci_next)
if(SIMinfo.deleteCircuit) SIMinfo.deleteCircuit(cc->ci_ckt);
#endif
2000-04-27 22:03:57 +02:00
byemesg();
}
2000-04-27 22:03:57 +02:00
else {
return;
}
} else
byemesg();
} else
byemesg();
2000-04-27 22:03:57 +02:00
exit(EXIT_NORMAL);
2000-04-27 22:03:57 +02:00
}
#ifdef SYSTEM_MAIL
void
com_bug(wordlist *wl)
{
char buf[BSIZE_SP];
2010-11-16 21:38:24 +01:00
NG_IGNORE(wl);
2010-11-16 20:11:32 +01:00
2000-04-27 22:03:57 +02:00
if (!Bug_Addr || !*Bug_Addr) {
fprintf(cp_err, "Error: No address to send bug reports to.\n");
return;
}
fprintf(cp_out, "Calling the mail program . . .(sending to %s)\n\n",
Bug_Addr);
fprintf(cp_out,
"Please include the OS version number and machine architecture.\n");
fprintf(cp_out,
"If the problem is with a specific circuit, please include the\n");
fprintf(cp_out, "input file.\n");
(void) sprintf(buf, SYSTEM_MAIL, ft_sim->simulator,
ft_sim->version, Bug_Addr);
(void) system(buf);
fprintf(cp_out, "Bug report sent. Thank you.\n");
return;
}
#else /* SYSTEM_MAIL */
2000-04-27 22:03:57 +02:00
void
com_bug(wordlist *wl)
{
2011-06-11 19:07:38 +02:00
NG_IGNORE(wl);
2003-08-05 19:20:17 +02:00
fprintf(cp_out, "Send mail to the address ngspice-devel@lists.sourceforge.net\n");
2000-04-27 22:03:57 +02:00
return;
}
#endif /* SYSTEM_MAIL */
2000-04-27 22:03:57 +02:00
void
com_version(wordlist *wl)
{
char *s;
if (!wl) {
fprintf(cp_out, "******\n");
fprintf(cp_out, "** %s-%s : %s\n", ft_sim->simulator,
ft_sim->version, ft_sim->description);
fprintf(cp_out, "** The U. C. Berkeley CAD Group\n");
fprintf(cp_out,
"** Copyright 1985-1994, Regents of the University of California.\n");
2010-09-25 16:15:26 +02:00
fprintf(cp_out, "** %s\n", Spice_Manual);
2008-11-22 11:31:46 +01:00
if (Spice_Notice != NULL && *Spice_Notice != 0)
2000-04-27 22:03:57 +02:00
fprintf(cp_out, "** %s\n", Spice_Notice);
2008-11-22 11:31:46 +01:00
if (Spice_Build_Date != NULL && *Spice_Build_Date != 0)
2000-04-27 22:03:57 +02:00
fprintf(cp_out, "** Creation Date: %s\n", Spice_Build_Date);
fprintf(cp_out, "******\n");
} else {
s = wl_flatten(wl);
if (!strncmp(s, "-s", 2) || !strncmp(s, "-S", 2) ) {
2000-04-27 22:03:57 +02:00
fprintf(cp_out, "******\n");
fprintf(cp_out, "** %s-%s\n", ft_sim->simulator,
ft_sim->version);
2010-09-25 16:15:26 +02:00
fprintf(cp_out, "** %s\n", Spice_Manual);
2008-11-22 11:31:46 +01:00
if (Spice_Notice != NULL && *Spice_Notice != 0)
2000-04-27 22:03:57 +02:00
fprintf(cp_out, "** %s\n", Spice_Notice);
2008-11-22 11:31:46 +01:00
if (Spice_Build_Date != NULL && *Spice_Build_Date != 0)
2000-04-27 22:03:57 +02:00
fprintf(cp_out, "** Creation Date: %s\n", Spice_Build_Date);
fprintf(cp_out, "******\n");
} else if (!strncmp(s, "-f", 2) || !strncmp(s, "-F", 2) ) {
fprintf(cp_out, "******\n");
fprintf(cp_out, "** %s-%s : %s\n", ft_sim->simulator,
ft_sim->version, ft_sim->description);
fprintf(cp_out, "** The U. C. Berkeley CAD Group\n");
fprintf(cp_out,
"** Copyright 1985-1994, Regents of the University of California.\n");
2010-09-25 16:15:26 +02:00
fprintf(cp_out, "** %s\n", Spice_Manual);
2008-11-22 11:31:46 +01:00
if (Spice_Notice != NULL && *Spice_Notice != 0)
fprintf(cp_out, "** %s\n", Spice_Notice);
2008-11-22 11:31:46 +01:00
if (Spice_Build_Date != NULL && *Spice_Build_Date != 0)
fprintf(cp_out, "** Creation Date: %s\n", Spice_Build_Date);
fprintf(cp_out,"**\n");
#ifdef CIDER
fprintf(cp_out,"** CIDER 1.b1 (CODECS simulator) included\n");
#endif
#ifdef XSPICE
fprintf(cp_out,"** XSPICE extensions included\n");
#endif
fprintf(cp_out,"** Relevant compilation options (refer to user's manual):\n");
#ifdef NOBYPASS
fprintf(cp_out,"** --enable-nobypass\n");
#endif
#ifdef CAPBYPASS
fprintf(cp_out,"** --enable-capbypass\n");
#endif
#ifdef NODELIMITING
fprintf(cp_out,"** --enable-nodelimiting\n");
#endif
#ifdef PREDICTOR
fprintf(cp_out,"** --enable-predictor\n");
#endif
#ifdef NEWTRUNC
fprintf(cp_out,"** --enable-newtrunc\n");
#endif
#ifdef WANT_SENSE2
fprintf(cp_out,"** --enable-sense2\n");
#endif
fprintf(cp_out,"**\n");
#ifdef EXPERIMENTAL_CODE
fprintf(cp_out,"** Experimental code enabled.\n");
#endif
#ifdef EXP_DEV
fprintf(cp_out,"** Experimental devices enabled.\n");
#endif
fprintf(cp_out, "******\n");
2000-04-27 22:03:57 +02:00
} else if (!eq(ft_sim->version, s)) {
fprintf(stderr,
"Note: rawfile is version %s (current version is %s)\n",
wl->wl_word, ft_sim->version);
}
tfree(s);
}
return;
}
static void
byemesg(void)
{
#if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE)
/* write out command history only when saying goodbye. */
if (cp_interactive && (cp_maxhistlength > 0)) {
stifle_history(cp_maxhistlength);
write_history(history_file);
}
#endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */
2000-04-27 22:03:57 +02:00
printf("%s-%s done\n", ft_sim->simulator, ft_sim->version);
return;
}