28 #include <sys/types.h> 32 #ifndef HAVE_GETRUSAGE 34 #include <sys/types.h> 35 #include <sys/timeb.h> 59 {
"", 0, 0, 0, 0, 0, 0,
79 static char *
usage =
"Usage: %s [ - ] [ -r rawfile ] [ file ... ]\n";
86 bool gi_endpause =
true;
101 "Usage: %s [-] [-b] [-i] [-s] [-n] [-o outfile] [-r rawfile]\n\ 102 \t[-t term] [file ...]\n";
123 extern struct comm spcp_coms[ ];
238 {
return (
"spice error"); }
243 char *name, *ckt, *value;
262 struct
line *l1, *l2;
269 #define FontWidth currentgraph->fontwidth 290 int x, y, bg, fg,
cc;
295 int editX, editY, editFg, editCc;
297 static char editBuf[128];
313 end = strchr(editBuf,
'\0');
319 DevText(ctmp, editX + (
int)(editC-editBuf)*FontWidth, editY);
322 if ((
char) k ==
'\r')
break;
326 if (editC >= end)
continue;
329 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
331 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
335 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
337 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
341 if (editC <= editBuf)
continue;
344 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
346 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
350 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
352 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
356 if (editC == editBuf)
continue;
358 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
360 DevText(editC,editX + (
int)(editC-editBuf)*FontWidth,editY);
363 strcat(editBuf,++editC);
364 DevText(editC,editX + (
int)(editC-editBuf)*FontWidth,editY);
366 if (end > editBuf) end--;
369 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
371 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
376 if (editC == end)
continue;
378 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
379 DevText(editC,editX + (
int)(editC-editBuf)*FontWidth,editY);
382 strcat(editBuf,++editC);
383 DevText(editC,editX + (
int)(editC-editBuf)*FontWidth,editY);
385 if (end > editBuf) end--;
388 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
390 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
397 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
399 editC = end = editBuf;
401 if ((
char) k ==
'\033') {
409 if (k > 255)
continue;
410 if (((
char) k <
' ') || ((
char) k >
'~'))
continue;
412 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
413 DevText(editC,editX + (
int)(editC-editBuf)*FontWidth,editY);
416 sprintf(++editC,tbuf);
420 editX+(
int)(editC-1-editBuf)*FontWidth,editY);
422 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
424 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
431 textcursor(editX+(
int)(editC-editBuf)*FontWidth,editY);
434 DevText(ctmp,editX + (
int)(editC-editBuf)*FontWidth,editY);
455 char *cmd_line_term = 0, term_1stch;
466 bool istty =
true, iflag =
false, qflag =
false;
467 bool readinit =
true;
469 bool read_err =
false;
477 fprintf(
cp_err,
"main: Internal Error: jump to zero\n");
497 mallocTraceInit(
"malloc.out");
500 istty = (
bool) isatty(fileno(stdin));
506 err =
SIMinit(&nutmeginfo,&ft_sim);
617 if (!(freopen(*tv,
"w", stdout))) {
630 fprintf(
cp_err,
"Error: bad option %s\n", *tv);
653 if ((iflag && !istty) || qflag)
685 if (setjmp(
jbuf) == 1) {
700 if (
access(
".spiceinit", 0) == 0)
703 pw = getpwuid(getuid());
704 (void)
strcpy(buf, pw->pw_dir);
705 (void) strcat(buf,
"/.spiceinit");
711 if ((fp = fopen(
"spice.rc",
"r")) !=
NULL) {
721 *cmd_line_term = term_1stch;
742 fprintf(
cp_err,
"Warning: error executing init file.\n");
749 if (setjmp(
jbuf) == 1) {
759 for (tv = av + 1, i = 0; *tv; tv++)
763 for (tv = av + 1, i = 0; *tv; tv++)
766 if (!(file = fopen(*tv,
"r"))) {
773 if (!(file = fopen(tempfile,
"w+"))) {
777 for (tv = av + 1, i = 0; *tv; tv++)
779 if (!(tp = fopen(*tv,
"r"))) {
783 while ((i = fread(buf, 1,
BSIZE_SP, tp)) > 0)
784 (void) fwrite(buf, i, 1, file);
787 (void) fseek(file, (
long) 0, 0);
804 for (av++; *av; av++)
826 if (ft_curckt ==
NULL) {
831 fprintf(
cp_err,
"Error: no circuit loaded!\n");
869 if (ft_curckt ==
NULL) {
874 fprintf(
cp_err,
"Error: no circuit loaded!\n");
890 "Note: \".plot\" or \".print\" lines ignored (rawfile only)\n");
931 CONSTe = exp((
double)1.0);
943 return (
SPIinit(frontEnd,simulator));
981 void cp_addkword(
class, word)
int class;
char *word; {}
982 struct circ *ft_circuits = 0, *ft_curckt = 0;
988 void Input(p, q)
char *
p, *q; {}
992 void NewViewport(i)
int i; {}
1001 void gr_pmsg(text, more)
char *text;
bool more; {}
1002 void gr_clean(intr)
bool intr; {}
1003 int cp_evloop(
string)
char *string; {
return (0); }
1036 for (dd = deck->
li_next; dd; dd = next) {
1038 if (
ciprefix(
".opt", dd->li_line)) {
1113 fprintf(
cp_out,
"Circuit: %s\nDate: %s\n\n", ft_curckt->
ci_name,
1129 (void) putc(
'\n',
cp_out);
1132 bad: fprintf(
cp_err,
"Internal Error: ft_cktcoms: bad commands\n");
1142 char *
t, *r,
buf[64];
1151 else if (!
index(t,
'(' )) {
1154 end->wl_next->wl_prev = end;
1159 end->wl_word =
copy(t);
1161 else if (!
index(t,
',')) {
1162 iflag = ((*t ==
'i') || (*t ==
'I')) ?
true :
false;
1166 for (r = t; *r && *r !=
')'; r++)
1171 end->wl_next->wl_prev = end;
1177 (void) sprintf(buf,
"%s#branch", t);
1180 end->wl_word =
copy(t);
1187 for (r = t; *r && *r !=
','; r++)
1192 end->wl_next->wl_prev = end;
1197 end->wl_word =
copy(t);
1199 for (r = t; *r && *r !=
')'; r++)
1204 end->wl_next->wl_prev = end;
1209 end->wl_word =
copy(t);
static char buf[MAXPROMPT]
char * if_errstring(code)
void inp_list(FILE *fp, struct line *l1, struct line *l2, int i)
bool cp_getvar(char *n, int t, char *r)
struct plot * plot_alloc()
struct variable * nutif_getparam()
static void textcursor(int x, int y)
void if_option(char *ckt, char *name, int type, char *value)
struct line * inp_getopts()
static void clear_previous()
static struct sSCEDitf sc_itf
struct variable *(* if_getparam)()
void inp_spsource(FILE *fp, bool i, char *s)
struct circ * ft_circuits
struct variable * if_getstat(char *n, char *c, wordlist **w)
static wordlist * gettoks()
wordlist * GetAnalysisFromDeck()
int access(char *pth, int m)
struct dvec * vec_fromplot()
char * KbEdit(char *s, int x, int y, int bg, int fg, int cc)
struct variable * cp_enqvar()
struct sSCEDitf * ft_sced
struct options * exitoption
static IFfrontEnd nutmeginfo
char * index(char *s, char c) const
struct wordlist * wl_next
int SPIinit(IFfrontEnd *frtEnd, IFsimulator **description)
struct variable * spif_getparam()
int SIMinit(IFfrontEnd *frontEnd, IFsimulator **simulator)
struct options * helpoption
int main(int ac, char **av)