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
|
2012-07-19 20:14:12 +02:00
|
|
|
***********/
|
2001-06-05 20:00:28 +02:00
|
|
|
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/ngspice.h"
|
|
|
|
|
#include "ngspice/cpdefs.h"
|
|
|
|
|
#include "ngspice/ftedefs.h"
|
|
|
|
|
#include "ngspice/dvec.h"
|
|
|
|
|
#include "ngspice/fteparse.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
#include "cpitf.h"
|
2010-10-16 19:09:46 +02:00
|
|
|
#include "com_let.h"
|
|
|
|
|
#include "com_set.h"
|
|
|
|
|
#include "define.h"
|
|
|
|
|
#include "misccoms.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2011-12-27 12:12:51 +01:00
|
|
|
#include "terminal.h"
|
2000-05-13 13:00:43 +02:00
|
|
|
|
2000-05-06 16:12:51 +02:00
|
|
|
#include "completion.h"
|
2000-06-27 18:09:02 +02:00
|
|
|
#include "variable.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
/* Set some standard variables and aliases, etc, and init the ccom stuff.
|
2009-08-15 11:27:47 +02:00
|
|
|
Called by fcn main() */
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ft_cpinit(void)
|
|
|
|
|
{
|
|
|
|
|
bool found = FALSE, t = TRUE;
|
2012-07-19 20:14:12 +02:00
|
|
|
char buf[BSIZE_SP], **x, *s, *r, *copys;
|
2000-04-27 22:03:57 +02:00
|
|
|
struct comm *c;
|
|
|
|
|
int i;
|
|
|
|
|
FILE *fp;
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static char *predefs[] = {
|
|
|
|
|
"yes", "1",
|
|
|
|
|
"TRUE", "1",
|
|
|
|
|
"no", "0",
|
|
|
|
|
"FALSE", "0",
|
|
|
|
|
"pi", "3.14159265358979323846",
|
|
|
|
|
"e", "2.71828182844590452353",
|
|
|
|
|
"c", "2.997925e8",
|
|
|
|
|
"i", "0,1",
|
|
|
|
|
"kelvin", "-273.15",
|
|
|
|
|
"echarge", "1.60219e-19",
|
|
|
|
|
"boltz", "1.38062e-23",
|
|
|
|
|
"planck", "6.62620e-34"
|
2012-07-19 20:14:12 +02:00
|
|
|
};
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static char *udfs[] = {
|
|
|
|
|
"max(x,y)", "(x gt y) * x + (x le y) * y",
|
|
|
|
|
"min(x,y)", "(x lt y) * x + (x ge y) * y",
|
|
|
|
|
"vdb(x)", "db(v(x))",
|
|
|
|
|
"vdb(x,y)", "db(v(x) - v(y))",
|
|
|
|
|
"vi(x)", "im(v(x))",
|
|
|
|
|
"vi(x,y)", "im(v(x) - v(y))",
|
|
|
|
|
"vm(x)", "mag(v(x))",
|
|
|
|
|
"vm(x,y)", "mag(v(x) - v(y))",
|
2009-01-15 22:08:09 +01:00
|
|
|
"vg(x)", "group_delay(v(x))", //A.Rroldan 10/06/05 group delay new function
|
2012-07-19 20:14:12 +02:00
|
|
|
"gd(x)", "group_delay(v(x))", //A.Rroldan 10/06/05 group delay new function
|
2009-08-15 11:27:47 +02:00
|
|
|
"vp(x)", "ph(v(x))",
|
2000-04-27 22:03:57 +02:00
|
|
|
"vp(x,y)", "ph(v(x) - v(y))",
|
|
|
|
|
"vr(x)", "re(v(x))",
|
|
|
|
|
"vr(x,y)", "re(v(x) - v(y))"
|
2012-07-19 20:14:12 +02:00
|
|
|
};
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2009-08-15 13:47:05 +02:00
|
|
|
/* if TIOCSTI is defined (not available in MS Windows:
|
|
|
|
|
Make escape the break character.
|
|
|
|
|
So the user can type ahead...
|
|
|
|
|
fcn defined in complete.c. */
|
|
|
|
|
cp_ccon(TRUE);
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2009-08-15 11:27:47 +02:00
|
|
|
/* Initialize io, cp_chars[], variable "history" in init.c. */
|
2000-04-27 22:03:57 +02:00
|
|
|
cp_init();
|
|
|
|
|
|
2009-08-15 13:47:05 +02:00
|
|
|
/* If command completion is available (global variable cp_nocc
|
2012-07-19 20:14:12 +02:00
|
|
|
set in main.c by command line option -q) */
|
2000-04-27 22:03:57 +02:00
|
|
|
if (!cp_nocc) {
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Add commands... */
|
|
|
|
|
for (c = cp_coms; c->co_func; c++) {
|
|
|
|
|
if (c->co_spiceonly && ft_nutmeg)
|
|
|
|
|
continue;
|
2012-07-19 20:14:12 +02:00
|
|
|
cp_addcomm(c->co_comname,
|
|
|
|
|
c->co_cctypes[0], c->co_cctypes[1],
|
|
|
|
|
c->co_cctypes[2], c->co_cctypes[3]);
|
2000-04-27 22:03:57 +02:00
|
|
|
cp_addkword(CT_COMMANDS, c->co_comname);
|
|
|
|
|
}
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* And keywords... These are the ones that are constant... */
|
|
|
|
|
if (!ft_nutmeg) {
|
|
|
|
|
cp_addkword(CT_LISTINGARGS, "deck");
|
|
|
|
|
cp_addkword(CT_LISTINGARGS, "logical");
|
|
|
|
|
cp_addkword(CT_LISTINGARGS, "physical");
|
|
|
|
|
cp_addkword(CT_LISTINGARGS, "expand");
|
|
|
|
|
|
|
|
|
|
cp_addkword(CT_STOPARGS, "when");
|
|
|
|
|
cp_addkword(CT_STOPARGS, "after");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cp_addkword(CT_PLOT, "new");
|
|
|
|
|
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "xlimit");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "ylimit");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "vs");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "xindices");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "xcompress");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "xdelta");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "ydelta");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "lingrid");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "loglog");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "linear");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "xlog");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "ylog");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "polar");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "smith");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "smithgrid");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "nointerp");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "title");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "xlabel");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "ylabel");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "linplot");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "combplot");
|
|
|
|
|
cp_addkword(CT_PLOTKEYWORDS, "pointplot");
|
|
|
|
|
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "time");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "space");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "faults");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "elapsed");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "totiter");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "traniter");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "tranpoints");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "accept");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "rejected");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "time");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "trantime");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "lutime");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "solvetime");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "transolvetime");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "loadtime");
|
|
|
|
|
cp_addkword(CT_RUSEARGS, "all");
|
|
|
|
|
|
|
|
|
|
cp_addkword(CT_VECTOR, "all");
|
|
|
|
|
|
|
|
|
|
for (x = ft_setkwords; *x; x++)
|
|
|
|
|
cp_addkword(CT_VARIABLES, *x);
|
|
|
|
|
for (i = 0; ; i++) {
|
2010-11-19 19:54:40 +01:00
|
|
|
if ((s = ft_typenames(i)) == NULL)
|
2000-04-27 22:03:57 +02:00
|
|
|
break;
|
|
|
|
|
cp_addkword(CT_TYPENAMES, s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-17 22:48:20 +02:00
|
|
|
cp_vset("program", CP_STRING, cp_program);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
/* Make the prompt use only the last component of the path... */
|
|
|
|
|
|
|
|
|
|
if (DIR_TERM) {
|
2012-07-19 20:26:13 +02:00
|
|
|
for (s = cp_program; s && *s; s++)
|
|
|
|
|
;
|
|
|
|
|
s--;
|
|
|
|
|
while ((s > cp_program) && (*s != DIR_TERM))
|
|
|
|
|
s--;
|
|
|
|
|
if (*s == DIR_TERM)
|
|
|
|
|
s++;
|
|
|
|
|
(void) strcpy(buf, s);
|
|
|
|
|
for (s = buf; *s && (*s != '.'); s++)
|
|
|
|
|
;
|
|
|
|
|
*s = '\0';
|
|
|
|
|
(void) strcat(buf, " ! -> ");
|
2012-07-19 20:14:12 +02:00
|
|
|
|
|
|
|
|
} else {
|
2012-07-19 20:26:13 +02:00
|
|
|
(void) sprintf(buf, "%s ! -> ", cp_program);
|
2012-07-19 20:14:12 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2010-07-17 22:48:20 +02:00
|
|
|
cp_vset("prompt", CP_STRING, buf);
|
2010-07-20 21:19:51 +02:00
|
|
|
cp_vset("noglob", CP_BOOL, &t);
|
|
|
|
|
cp_vset("brief", CP_BOOL, &t);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
/* Make vectors from values in predefs[] for the current plot.
|
|
|
|
|
Define functions from entries in udfs[] (like user defined functions).
|
|
|
|
|
*/
|
2012-07-19 20:15:30 +02:00
|
|
|
|
|
|
|
|
{
|
2012-07-19 20:14:12 +02:00
|
|
|
wordlist wl1, wl2, wl3;
|
|
|
|
|
wl1.wl_next = &wl2;
|
|
|
|
|
wl1.wl_prev = NULL;
|
|
|
|
|
wl2.wl_next = NULL;
|
|
|
|
|
wl2.wl_prev = &wl1;
|
|
|
|
|
wl1.wl_word = "if";
|
|
|
|
|
wl2.wl_word = "1";
|
|
|
|
|
cp_setalias("begin", &wl1);
|
|
|
|
|
wl1.wl_next = NULL;
|
|
|
|
|
wl1.wl_word = "end";
|
|
|
|
|
cp_setalias("endif", &wl1);
|
|
|
|
|
cp_setalias("endwhile", &wl1);
|
|
|
|
|
cp_setalias("endforeach", &wl1);
|
|
|
|
|
cp_setalias("endrepeat", &wl1);
|
|
|
|
|
cp_setalias("enddowhile", &wl1);
|
|
|
|
|
wl1.wl_word = "help";
|
|
|
|
|
cp_setalias("?", &wl1);
|
|
|
|
|
|
|
|
|
|
wl1.wl_next = &wl2;
|
|
|
|
|
wl2.wl_next = &wl3;
|
|
|
|
|
wl2.wl_prev = &wl1;
|
|
|
|
|
wl3.wl_prev = &wl2;
|
|
|
|
|
wl3.wl_next = NULL;
|
|
|
|
|
wl2.wl_word = "=";
|
|
|
|
|
for (i = 0; (size_t) i < NUMELEMS(predefs); i += 2) {
|
|
|
|
|
wl1.wl_word = predefs[i];
|
|
|
|
|
wl3.wl_word = predefs[i + 1];
|
|
|
|
|
com_let(&wl1);
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
wl2.wl_next = NULL;
|
|
|
|
|
for (i = 0; (size_t) i < NUMELEMS(udfs); i += 2) {
|
|
|
|
|
wl1.wl_word = udfs[i];
|
|
|
|
|
wl2.wl_word = udfs[i + 1];
|
|
|
|
|
com_define(&wl1);
|
|
|
|
|
}
|
2012-07-19 20:15:30 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
/* Reset this for the front end. */
|
|
|
|
|
cp_hash = '*';
|
|
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
/* NGSPICEDATADIR has been set to path "$dprefix/share/ngspice" in configure.ac,
|
|
|
|
|
Spice_Lib_Dir has been set to NGSPICEDATADIR in conf.c,
|
2009-08-15 11:27:47 +02:00
|
|
|
may be overridden by environmental variable SPICE_LIB_DIR in ivars().
|
2009-06-11 16:12:07 +02:00
|
|
|
Lib_Path has been set to Spice_Lib_Dir adding /scripts in ivars() */
|
2000-04-27 22:03:57 +02:00
|
|
|
if (Lib_Path && *Lib_Path) {
|
2012-07-19 20:14:12 +02:00
|
|
|
/* set variable 'sourcepath' */
|
|
|
|
|
if (Inp_Path && *Inp_Path)
|
2011-06-25 18:03:05 +02:00
|
|
|
(void) sprintf(buf, "sourcepath = ( %s %s %s )", DIR_CWD, Lib_Path, Inp_Path);
|
|
|
|
|
else
|
|
|
|
|
(void) sprintf(buf, "sourcepath = ( %s %s )", DIR_CWD, Lib_Path);
|
2012-07-19 20:15:30 +02:00
|
|
|
|
|
|
|
|
{
|
2012-07-19 20:14:12 +02:00
|
|
|
wordlist *wl;
|
|
|
|
|
wl = cp_doglob(cp_lexer(buf));
|
|
|
|
|
cp_striplist(wl);
|
|
|
|
|
com_set(wl);
|
|
|
|
|
wl_free(wl);
|
2012-07-19 20:15:30 +02:00
|
|
|
}
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2009-08-15 11:27:47 +02:00
|
|
|
/* Now source the standard startup file spinit or tclspinit. */
|
2008-12-23 19:04:51 +01:00
|
|
|
|
2009-06-11 22:16:20 +02:00
|
|
|
/* jump over leading spaces */
|
2012-07-19 20:14:12 +02:00
|
|
|
for (copys = s = cp_tildexpand(Lib_Path); copys && *copys; ) {
|
2009-06-11 16:12:07 +02:00
|
|
|
while (isspace(*s))
|
|
|
|
|
s++;
|
2009-06-11 22:16:20 +02:00
|
|
|
/* copy s into buf until space is seen, r is the actual position */
|
|
|
|
|
for (r = buf; *s && !isspace(*s); r++, s++)
|
|
|
|
|
*r = *s;
|
|
|
|
|
tfree(copys);
|
2012-07-19 20:14:12 +02:00
|
|
|
/* add a path separator to buf at actual position */
|
2009-06-11 22:16:20 +02:00
|
|
|
(void) strcpy(r, DIR_PATHSEP);
|
2008-11-23 21:47:23 +01:00
|
|
|
#ifdef TCL_MODULE
|
2009-06-11 22:16:20 +02:00
|
|
|
/* add "tclspinit" to buf after actual position */
|
|
|
|
|
(void) strcat(r, "tclspinit");
|
2008-11-23 21:47:23 +01:00
|
|
|
#else
|
2009-06-11 22:16:20 +02:00
|
|
|
/* add "spinit" to buf after actual position */
|
|
|
|
|
(void) strcat(r, "spinit");
|
2008-11-23 21:47:23 +01:00
|
|
|
#endif
|
2010-11-19 19:52:44 +01:00
|
|
|
if ((fp = fopen(buf, "r")) != NULL) {
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2009-06-11 22:16:20 +02:00
|
|
|
cp_interactive = FALSE;
|
|
|
|
|
inp_spsource(fp, TRUE, buf);
|
|
|
|
|
cp_interactive = TRUE;
|
|
|
|
|
found = TRUE;
|
|
|
|
|
break;
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
#if defined(HAS_WINDOWS) || defined(__MINGW32__) || defined(_MSC_VER)
|
2012-07-19 20:14:12 +02:00
|
|
|
/* search in local directory where ngspice.exe resides */
|
2012-02-10 17:59:33 +01:00
|
|
|
#if defined TCL_MODULE
|
|
|
|
|
} else if ((fp = fopen("./tclspinit", "r")) != NULL) {
|
|
|
|
|
#else
|
2010-11-19 19:52:44 +01:00
|
|
|
} else if ((fp = fopen("./spinit", "r")) != NULL) {
|
2012-02-10 17:59:33 +01:00
|
|
|
#endif
|
2009-08-15 11:27:47 +02:00
|
|
|
cp_interactive = FALSE;
|
|
|
|
|
inp_spsource(fp, TRUE, buf);
|
|
|
|
|
cp_interactive = TRUE;
|
|
|
|
|
found = TRUE;
|
|
|
|
|
break;
|
2012-07-19 20:14:12 +02:00
|
|
|
#endif
|
2012-09-20 20:30:53 +02:00
|
|
|
} else if (ft_controldb) {
|
2009-06-11 22:16:20 +02:00
|
|
|
fprintf(cp_err, "Note: can't open \"%s\".\n", buf);
|
2012-09-20 20:30:53 +02:00
|
|
|
}
|
2009-06-11 16:12:07 +02:00
|
|
|
}
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2009-06-11 16:12:07 +02:00
|
|
|
if (!found)
|
|
|
|
|
fprintf(cp_err, "Note: can't find init file.\n");
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
tcap_init();
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Decide whether a condition is TRUE or not. */
|
|
|
|
|
|
|
|
|
|
bool
|
2001-02-09 20:46:36 +01:00
|
|
|
cp_istrue(wordlist *wl)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
struct dvec *v;
|
2012-10-01 17:59:40 +02:00
|
|
|
struct pnode *names;
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
/* First do all the csh-type stuff here... */
|
|
|
|
|
wl = wl_copy(wl);
|
|
|
|
|
wl = cp_variablesubst(wl);
|
|
|
|
|
wl = cp_bquote(wl);
|
|
|
|
|
cp_striplist(wl);
|
|
|
|
|
|
2012-10-01 17:59:40 +02:00
|
|
|
names = ft_getpnames(wl, TRUE);
|
2009-04-05 10:02:03 +02:00
|
|
|
wl_free(wl);
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2012-10-01 17:59:40 +02:00
|
|
|
v = ft_evaluate(names);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
for (; v; v = v->v_link2)
|
2000-04-27 22:03:57 +02:00
|
|
|
if (isreal(v)) {
|
|
|
|
|
for (i = 0; i < v->v_length; i++)
|
2003-07-23 21:36:39 +02:00
|
|
|
if (v->v_realdata[i] != 0.0) {
|
2012-10-01 17:59:40 +02:00
|
|
|
free_pnode(names);
|
2012-07-19 20:14:12 +02:00
|
|
|
return (TRUE);
|
2012-07-19 20:26:13 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
|
|
|
|
for (i = 0; i < v->v_length; i++)
|
2012-02-07 20:53:12 +01:00
|
|
|
if ((realpart(v->v_compdata[i]) != 0.0) ||
|
|
|
|
|
(imagpart(v->v_compdata[i]) != 0.0)) {
|
2012-10-01 17:59:40 +02:00
|
|
|
free_pnode(names);
|
2000-04-27 22:03:57 +02:00
|
|
|
return (TRUE);
|
2012-07-19 20:26:13 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-07-19 20:14:12 +02:00
|
|
|
|
2012-10-01 17:59:40 +02:00
|
|
|
free_pnode(names);
|
2012-07-19 20:14:12 +02:00
|
|
|
return (FALSE);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
/* This gets called before every command is executed...
|
2009-08-15 11:55:44 +02:00
|
|
|
from fcns do_command() or do_block() in control.c */
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
cp_periodic(void)
|
|
|
|
|
{
|
2004-01-10 22:39:36 +01:00
|
|
|
ft_setflag = FALSE;
|
|
|
|
|
ft_intrpt = FALSE;
|
2009-08-15 11:55:44 +02:00
|
|
|
ft_ckspace(); /* check for max. data size (resource.c) */
|
|
|
|
|
ft_checkkids(); /* check for jobs (only if OK_ASPICE is defined, apsice.c) */
|
|
|
|
|
vec_gc(); /* remove vectors which do not have permanent flag set (vectors.c) */
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
void
|
|
|
|
|
cp_doquit(void)
|
|
|
|
|
{
|
2010-06-23 19:40:56 +02:00
|
|
|
com_quit(NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* This is how we deal with emulation of commands by scripts... If the script
|
|
|
|
|
* is found, then set the variables argc and argv and call the script. Note
|
|
|
|
|
* that this also allows us to type a filename to load a spice deck...
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
cp_oddcomm(char *s, wordlist *wl)
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
2010-11-19 19:52:44 +01:00
|
|
|
if ((fp = inp_pathopen(s, "r")) != NULL) {
|
2012-08-04 22:26:04 +02:00
|
|
|
char buf[BSIZE_SP];
|
|
|
|
|
wordlist *setarg;
|
2000-04-27 22:03:57 +02:00
|
|
|
(void) fclose(fp);
|
|
|
|
|
(void) sprintf(buf, "argc = %d argv = ( ", wl_length(wl));
|
|
|
|
|
while (wl) {
|
|
|
|
|
(void) strcat(buf, wl->wl_word);
|
|
|
|
|
(void) strcat(buf, " ");
|
|
|
|
|
wl = wl->wl_next;
|
|
|
|
|
}
|
|
|
|
|
(void) strcat(buf, ")");
|
2012-08-04 22:26:04 +02:00
|
|
|
setarg = cp_lexer(buf);
|
|
|
|
|
com_set(setarg);
|
|
|
|
|
wl_free(setarg);
|
2000-04-27 22:03:57 +02:00
|
|
|
inp_source(s);
|
|
|
|
|
cp_remvar("argc");
|
|
|
|
|
cp_remvar("argv");
|
|
|
|
|
return (TRUE);
|
2012-07-19 20:14:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wl && eq(wl->wl_word, "=")) {
|
2012-07-19 20:15:30 +02:00
|
|
|
wordlist *ww = wl_cons(copy(s), wl);
|
|
|
|
|
com_let(ww);
|
2012-07-29 12:40:00 +02:00
|
|
|
wl_delete_slice(ww, ww->wl_next);
|
2000-04-27 22:03:57 +02:00
|
|
|
return (TRUE);
|
2012-07-19 20:14:12 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-07-19 20:14:12 +02:00
|
|
|
return (FALSE);
|
|
|
|
|
}
|