home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / education / n / spice / docs / FTE / ME / FRONTEND
Text File  |  1988-01-27  |  21KB  |  585 lines

  1. .\" RCS Info: $Revision: 1.2 $ on $Date: 85/09/16 17:33:49 $
  2. .\"           $Source: /cad4/faustus/spice/doc/RCS/frontend.me,v $
  3. .\" Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
  4. .th
  5. .ds S \s-2SPICE\s+2\&3
  6. .+c "Front End"
  7. .pp
  8. \fBNote: there is a lot in this section that is out of date, but
  9. the code is in such a condition that it will have to be cleaned
  10. up a great deal before I can update the documentation...\fR
  11. .pp
  12. The \*S front end (FTE) is designed to be easily adaptable
  13. to different programs. There are several important parts: the
  14. "C-shell parser", which handles aliases, history, and the other csh-type
  15. functions, which is completely modular and may easily be used with 
  16. other programs; the routines for the various commands; the parser for
  17. algebraic expressions; the expression
  18. evaluation routines; the complex math routines; and the plotting
  19. routines.
  20. .pp
  21. The global front-end routines and variables
  22. are all prefixed with these characters (there are some exceptions in 
  23. "std.c"):
  24. .(b
  25. \fBcom_\fR    Front-end command routines
  26. \fBcp_\fR    C-shell parser routines and variables
  27. \fBcx_\fR    Complex math routines
  28. \fBdg_\fR    Diagnostic stuff like stack backtrace routines
  29. \fBft_\fR    General front-end routines and variables
  30. \fBgr_\fR    Graphics routines
  31. \fBif_\fR    \*S interface routines
  32. \fBinp_\fR    Input routines
  33. \fBsp_\fR    \*S variables
  34. \fBwl_\fR    Routines to do wordlist manipulation
  35. \fBwl_\fR    Wordlist manipulation routines
  36. \fBwrd_\fR    Routines in the \fBwritedata\fR package
  37. .)b
  38. .sh 2 "Csh Parser"
  39. .pp
  40. The C-shell parser (\fBcshpar\fR) does aliasing, history, quoting,
  41. backquote evaluation, globbing (expansion of *, ?, ~, {}, and []), 
  42. filename, command, and keyword completion, and
  43. IO redirection. It is supposed to function the same way that the
  44. C-shell does, so unless otherwise noted the C Shell User's Manual
  45. should be consulted for the details of how these operate.
  46. .pp
  47. To use \fBcshpar\fR, the file "FTEcshpar.h" should be included.
  48. The host program then must call
  49. .(b
  50. cp_parse(string);
  51. .)b
  52. If \fIstring\fR is non-NULL then the string will be used for input
  53. instead of the current input file.
  54. This will return a doubly-linked list of words in the following
  55. format:
  56. .(b
  57. \fBtypedef struct\fR wordlist {
  58.     \fBchar\fR *wl_word;            /* The word. */
  59.     \fBstruct\fR wordlist *wl_next;        /* Forward link. */
  60.     \fBstruct\fR wordlist *wl_prev;        /* Backward link. */
  61. } wordlist;
  62. .)b
  63. The list will be what the user typed, after alias substitutions, etc.
  64. The user must supply two routines:
  65. .(b
  66. cp_userset(var, isset)
  67.     \fBstruct\fR variable *var;
  68.     \fBbool\fR isset;
  69. .)b
  70. which \fBcshpar\fR calls if a variable that it doesn't know about
  71. gets set (it knows about such variables as \fIprompt, noglob,
  72. history,\fR and \fIverbose\fR).
  73. The \fIisset\fR argument is \fBtrue\fR (\fBbool\fR is typedef'd as
  74. \fBchar\fR, with \fBtrue\fR = (\fBchar\fR) 1 and \fBfalse\fR = 
  75. (\fBchar\fR) 0) if the variable has been set, and \fBfalse\fR if the
  76. variable has been unset.
  77. If the host program doesn't care about any variables, the function can
  78. just be a dummy routine. Also required is
  79. .(b
  80. \fBstruct\fR variable
  81. cp_enqvar(word)
  82.     \fBchar\fR *word;
  83. .)b
  84. which gets called when \fBcshpar\fR doesn't know about a variable mentioned \-
  85. if the host program doesn't know about the variable either it should return
  86. NULL.
  87. .pp
  88. The definition for the variable
  89. structure is
  90. .(b
  91. \fBstruct\fR variable {
  92.     \fBchar\fR va_type;        /* The type (see below). */
  93.     \fBchar\fR *va_name;        /* The variable name. */
  94.     \fBunion\fR {            /* The value of the variable. */
  95.         \fBbool\fR vV_bool;
  96.         \fBlong\fR vV_num;
  97.         \fBdouble\fR vV_real;
  98.         \fBchar\fR *vV_string;
  99.         \fBstruct\fR variable *vV_list;
  100.     } va_V;
  101.     \fBstruct\fR variable *va_next;        /* Forward link. */
  102.     \fBstruct\fR variable *va_prev;        /* Backward link. */
  103. } ;
  104.  
  105. #\fBdefine\fR va_bool        va_V.vV_bool
  106. #\fBdefine\fR va_num        va_V.vV_num
  107. #\fBdefine\fR va_real        va_V.vV_real
  108. #\fBdefine\fR va_string        va_V.vV_string
  109. #\fBdefine\fR va_list        va_V.vV_list
  110.  
  111. #\fBdefine\fR VT_BOOL        1
  112. #\fBdefine\fR VT_NUM        2
  113. #\fBdefine\fR VT_REAL        3
  114. #\fBdefine\fR VT_STRING        4
  115. #\fBdefine\fR VT_LIST        5
  116. .)b
  117. .pp
  118. In addition to these entry points, the behavior of \fBcshpar\fR can be
  119. changed with the routine
  120. .(b
  121. cp_modify(c, what)
  122.     \fBchar\fR c;
  123. .)b
  124. where \fIwhat\fR is one of:
  125. .(b
  126. #\fBdefine\fR CPM_REGC    1    /* Character made non-special to the parser. */
  127. #\fBdefine\fR CPM_DEF    2    /* Character restored to default meaning. */
  128. #\fBdefine\fR CPM_BRR    3    /* Break to right of character. */
  129. #\fBdefine\fR CPM_BRL    4    /* Break to left of character. */
  130. #\fBdefine\fR CPM_ALONE    5    /* Make character a single word. */
  131. #\fBdefine\fR CPM_NOBRK    6    /* Don't break at character. */
  132. #\fBdefine\fR CPM_NOAL    7    /* No aliasing. */
  133. #\fBdefine\fR CPM_AL    8    /* Aliasing. */
  134. #\fBdefine\fR CPM_INTER    9    /* Interactive mode. */
  135. #\fBdefine\fR CPM_NOINTER 10    /* Noninteractive mode (sources, etc). */
  136. .)b
  137. and \fIc\fR is a character, if one is required. (Otherwise it is
  138. ignored.)  Making a character non-special usually prevents some action
  139. from being carried out -- for instance, making the character *
  140. non-special prevents it from being expanded into filenames. This is
  141. done with \*S, as it is used for multiplication. Setting
  142. non-interactive mode prevents a prompt from being displayed and
  143. command and keyword completion from being done.
  144. To do a source, one would set non-interactive mode with
  145. .(b
  146. cp_modify((\fBchar\fR) 0, CPM_NOINTER);
  147. .)b
  148. and the change the FILE pointer \fIcp_curinput\fR to the desired input
  149. stream. When \fIcp_parse\fR returns \fBNULL\fR, then the end of file
  150. has been reached and \fIcp_curinput\fR should be reset to whatever it
  151. was before.
  152. .pp
  153. The characters that are used for the various functions generally
  154. may be changed: the variables (all \fBchar\fR's) containing them
  155. are as follows:
  156. .(b
  157.     Function    Variable    Default
  158.  
  159.     history        cp_bang        !
  160.     substitute    cp_hat        ^    (this is , in the front end)
  161.     variables    cp_dol        $
  162.     wildcard    cp_star        *
  163.     wildcard    cp_huh        ?
  164.     wildcard    cp_obrac    [
  165.     wildcard    cp_cbrac    ]
  166.     home directory    cp_til    ~
  167.     expansion    cp_ocurl    {
  168.     expansion    cp_ccurl    }
  169.     expansion    cp_comma    ,
  170.     input redirect    cp_lt        <
  171.     output redirect    cp_gt        >
  172.     error redirect    cp_amp        &
  173.     comment        cp_hash        #    (this is * in the front end)
  174. .)b
  175. If the variable \fInoglob\fR is set, this inhibits expansion of the
  176. wildcard characters *, ?, [, and ].
  177. .pp
  178. If the host program wants to take advantage of the IO redirection
  179. features of the front-end, it should use the FILE pointers
  180. \fBcp_in, cp_out,\fR and \fBcp_err\fR instead of \fBstdin, stdout,
  181. \fRand\fB stderr\fR. These are reset every time \fBcp_parse\fR is
  182. called.
  183. Whenever the user uses '>' or '<', the appropriate file is opened and the
  184. \fBcp_\fR FILE pointers are set to that file.
  185. .pp
  186. A few routines are available for setting and unsetting aliases,
  187. setting and unsetting variables, and printing history, aliases, and
  188. variables:
  189. .pp
  190. .(b
  191. cp_setalias(word, substitute)
  192.     \fBchar\fR *word;
  193.     wordlist *substitute;
  194. .)b
  195. The substitute list may contain history substitution characters, which
  196. operate on the current argument list.
  197. .(b
  198. cp_unalias(word)
  199.     \fBchar\fR *word;
  200. .)b
  201. If \fIword\fR has an alias then it is removed.
  202. .(b
  203. cp_vset(varname, type, value)
  204.     \fBchar\fR *varname;
  205.     \fBchar\fR *value;
  206. .)b
  207. The variable called \fIvarname\fR with the type \fItype\fR (see the
  208. VT_ defines above) is set to the value pointed to by \fIvalue\fR (of
  209. whatever type is specified by the \fItype\fR argument.)
  210. .(b
  211. cp_getvar(name, type, value)
  212.     \fBchar\fR *name;
  213.     \fBchar\fR *value;
  214. .)b
  215. The value of the variable with the given name and type is stored in
  216. the object pointed to by \fIvalue\fR.  \fIValue\fR should be an array
  217. of \fBchar\fR's is \fItype\fR is \fIVT_STRING\fR, an \fBint\fR * if 
  218. it is \fIVT_NUM\fR, and so forth. If the variable is defined with a
  219. different type, it is converted to the desired type if possible.
  220. .(b
  221. cp_remvar(varname)
  222.     \fBchar\fR *varname;
  223. .)b
  224. If there is a variable called \fIvarname\fR then it is deleted.
  225. .(b
  226. cp_vprint()
  227. .)b
  228. Print the values of all the variables currently defined.
  229. .(b
  230. cp_paliases(name)
  231.     \fBchar\fR *name;
  232. .)b
  233. Print the alias associated with \fIname\fR, or all aliases if the name
  234. is NULL.
  235. .(b
  236. cp_hprint(eventhi, eventlo)
  237. .)b
  238. Print the history from event number \fIeventhi\fR to event number 
  239. \fIeventlo\fR.
  240. .(b
  241. cp_addcomm(word, keywords, filec)
  242.     \fBchar\fR *word;
  243.     \fBwordlist\fR *keywords;
  244.     \fBbool\fR filec;
  245. .)b
  246. Add the command \fIword\fR to the list used for command completion.
  247. If \fIkeywords\fR is non-NULL then these keywords are used for
  248. keyword completion for this command, in addition to the global
  249. keyword list, which is \fIcp_keywords\fR (also a wordlist, which
  250. the host program may alter at any time). If the \fIfilec\fR argument
  251. is \fItrue\fR, then instead of keyword completion, filename and user
  252. name completion is done for this command. There is no way to
  253. specifiy certain arguments as being filenames and certain ones
  254. as keywords, etc.  The keyword lists and file completion flags
  255. will also work when a command is aliased, but not through
  256. history substitutions (yet).
  257. .pp
  258. When EOF (control-D) is typed, then \fIcshpar\fR prints out the
  259. alternatives that the user may type at this point, and when
  260. escape is typed then \fIcshpar\fR attempts to complete as much of
  261. the command, keyword, or filename already typed as it can.
  262. .(b
  263. cp_remcomm(word)
  264.     \fBchar\fR *word;
  265. .)b
  266. Remove \fIword\fR from the list of commands that may be completed,
  267. if it is there.
  268. .(b
  269. cp_addkword(word)
  270.     \fBchar\fR *word;
  271. .)b
  272. Add a keyword to the default list of keywords for keyword completion.
  273. These are in addition to keywords specific to particular commands.
  274. .(b
  275. cp_addkword(word)
  276.     \fBchar\fR *word;
  277. .)b
  278. Remove the keyword from the default list, if it is there.
  279. .pp
  280. There are several commands that the host program should recognise and
  281. call the proper routines for -- they all take wordlists as arguments (the
  282. \fIcdr\fR of the wordlist returned by \fBcp_parse\fR) and are
  283. as follows:
  284. .(b
  285.     Name    Function
  286.  
  287.     set    cp_cset
  288.     unset    cp_cunset
  289.     alias    cp_calias
  290.     unalias    cp_cualias
  291.     history    cp_chistory
  292.     echo    cp_cecho
  293. .)b
  294. .pp
  295. One note about using \fIcshpar\fR -- if you type a word as "word",
  296. it will be returned by \fIcp_parse\fR with the quotes on, so
  297. you should always use \fIcp_unquote()\fR with it. (This doesn't
  298. happen with single-quoted arguments -- the reason it is useful
  299. with double quotes is to be able to distinguish between strings
  300. and numbers if they are written the same.) The way that \fIcshpar\fR
  301. quotes characters with single quotes and backslashes is by turning
  302. on the eighth bit, which is unfortunately slightly non-portable
  303. but is pretty easy to deal with...
  304. .sh 2 "The Basic Command Interpreter"
  305. .pp
  306. The front end maintains a list of the commands available to it -- there 
  307. is a array called \fIComs\fR in the file "front.c" of the 
  308. following structures:
  309. .(b
  310. \fBstruct\fR comm {
  311.     \fBchar\fR *co_comname;    /* The name of the command. */
  312.     \fBint\fR (*co_func) ();    /* The function that handles the command. */
  313.     \fBbool\fR co_stringargs;    /* Collapse the arguments into a string. */
  314.     \fBbool\fR co_spiceonly;    /* These can't be used from nutmeg. */
  315.     \fBbool\fR co_filec;        /* Do filename completion. */
  316.     \fBint\fR co_minargs;        /* Minimum number of args. */
  317.     \fBint\fR co_maxargs;        /* Maximum number of args. */
  318.     \fBchar\fR *co_help;    /* A short help string. */
  319. } ;
  320. .)b
  321. If the \fIco_stringargs\fR field is \fBtrue\fR, then the function will
  322. be passed its arguments in a string, otherwise it will be passed a
  323. wordlist. If \fIco_spiceonly\fR is true and the program that is
  324. being run is \fInutmeg\fR, then the command will not be executed, as
  325. it is \*S-specific.
  326. The help function prints the help string with
  327. .(b
  328. printf(helpstring, ft_program);
  329. .)b
  330. where \fIft_program\fR is a global string containing the name of the
  331. current program (argv[0]), so the help string may contain a "%s" in
  332. the place of the program name.
  333. .pp
  334. Any routines that are added to the front end may be made usable simply
  335. by adding an entry to the ft_coms array. (Also, if there are any special
  336. keywords for this command, see the stuff in the function \fIcpinit\fR
  337. in "front.c". This isn't well done, because it is there just to show
  338. off keyword completion.)
  339. .pp
  340. If any options are
  341. added to \*S (which go on the .options card), its name, type, and
  342. code number (as in PARMdefs.h) should be 
  343. added to the \fIopts\fR array in spiceonly.c.
  344. .pp
  345. \*S data is stored in the front end in two ways. First, there is the 
  346. \fIspicedata\fR format, which is more like the way the data is saved in
  347. files (the data arrays are by points instead of vectors, as this is the
  348. way \*S outputs them), and is used only in the file "format.c" and routines
  349. like \fIwrite\fR and \fIload\fR.
  350. .pp
  351. The more usual format is defined in "FTEdata.h":
  352. .(b
  353. \fBstruct\fR dvec {
  354.     \fBchar\fR *v_name;        /* The name of the vector. */
  355.     \fBint\fR v_type;        /* The vector type (see FTEspicedata.h) */
  356.     \fBshort\fR v_flags;        /* Flags: */
  357.  
  358. #\fBdefine\fR VF_REAL        000001    /* The data is complex. */
  359. #\fBdefine\fR VF_COMPLEX    000002    /* The data is real. */
  360. #\fBdefine\fR VF_UPLIM    000004    /* An upper limit is in effect (see below). */
  361. #\fBdefine\fR VF_LOWLIM    000010    /* A lower limit is in effect. */
  362. #\fBdefine\fR VF_ACCUM    000020    /* writedata() should accumulate this vector. */
  363. #\fBdefine\fR VF_PLOT        000040    /* writedata() should incrementally plot it. */
  364. #\fBdefine\fR VF_PRINT    000100    /* writedata() should print this vector. */
  365.  
  366.     \fBunion\fR {
  367.         \fBdouble\fR *vU_realdata;
  368.         \fBcomplex\fR *vU_compdata;
  369.     } v_U;            /* The actual data. */
  370.  
  371. #\fBdefine\fR v_realdata    v_U.vU_realdata
  372. #\fBdefine\fR v_compdata    v_U.vU_compdata
  373.  
  374. #\fBdefine\fR isreal(v)    ((v)->v_flags & VF_REAL)
  375. #\fBdefine\fR iscomplex(v)    ((v)->v_flags & VF_COMPLEX)
  376.  
  377.     \fBint\fR v_length;        /* Length of the vector. */
  378.     \fBint\fR v_rlength;        /* How much space we really have. */
  379.     \fBdouble\fR v_yhi;        /* The upper and lower y limits, if this */
  380.     \fBdouble\fR v_ylo;        /* is a dvec to be plotted. */
  381.     \fBint\fR v_outindex;        /* Index if writedata is building the vector. */
  382.     \fBint\fR v_linestyle;        /* What line style we are using. */
  383.     \fBint\fR v_color;        /* What color we are using. */
  384.     \fBbool\fR v_permanent;        /* Don't garbage collect this dvec. */
  385.  
  386.     \fBstruct\fR plot *v_plot;    /* The plot structure (if it has one). */
  387.     \fBstruct\fR dvec *v_next;    /* Forward link. */
  388.     \fBstruct\fR dvec *v_link2;    /* Extra link for use with some commands. */
  389. } ;
  390. .)b
  391. All the dvecs that are available are linked together under \fIft_plots\fR,
  392. which correspond to seperate \*S runs. The current plot is where
  393. vectors are searched for first by name, and is pointed to by the
  394. variable \fBft_curplot\fR. The plot structure is as follows:
  395. .(b
  396. \fBstruct\fR plot {
  397.     \fBchar\fR *pl_title;        /* The title card. */
  398.     \fBchar\fR *pl_date;        /* Date. */
  399.     \fBchar\fR *pl_name;        /* The plot name. */
  400.     \fBstruct\fR dvec *pl_dvecs;    /* The data vectors in this plot. */
  401.     \fBstruct\fR dvec *pl_scale;    /* The "scale" for the rest of the vectors. */
  402.     \fBstruct\fR plot *pl_next;    /* List of plots. */
  403.     \fBwordlist\fR *pl_commands;    /* Commands to execute when this plot is set. */
  404. } ;
  405. .)b
  406. In order to get a \fIdvec\fR, given a name, the function 
  407. \fBft_vecbyname(name)\fR, where \fIname\fR is the name of the desired
  408. vector, is used. This tries to find the named vector, and if it can't
  409. it then tried "\fBV(name)\fR" and "\fBI(name)\fR". It limits the search
  410. to the current plot.
  411. .sh 2 "Functions"
  412. .pp
  413. There is a table of data on the available functions in the file
  414. psubr.c, of the form:
  415. .(b
  416. \fBstruct\fR func {
  417.     \fBchar\fR *fu_name;            /* The print name of the function. */
  418.     \fBcomplex\fR *(*fu_func)();        /* The function. */
  419. } ;
  420. .)b
  421. When an expression like \fIsin (foo)\fR is parsed, the routines in
  422. psubr.c try to find a function in the \fIfuncs\fR table called 
  423. \fIsin\fR. If there is one, then a function node is added to the parse
  424. tree (see FTEparse.h), but if there is none, then a vector named
  425. \fIsin(foo)\fR is checked for.  Also if a name of the form \fBtype(name)\fR
  426. is given, where \fBtype\fR can be \fBV\fR or \fBI\fR, a vector with
  427. name \fBname\fR will match.
  428. When a parse tree is evaluated with the
  429. function \fIevaluate(parsenode)\fR, and a function node is
  430. encountered, then the routine \fIapply_func\fR applies the appropriate
  431. complex math routine to each point of the data vector to obtain the
  432. new vector.
  433. .pp
  434. To add a new function, it is necessary to add a \fIfunc\fR structure to
  435. the above array, and add the function referenced by \fIfu_func\fR
  436. to "cmath.c".
  437. .pp
  438. Complex math functions are called in the following manner:
  439. .(b
  440.     \fBchar\fR *
  441.     cx_function (data, type, length, newlength, newtype)
  442.         \fBchar\fR *data;
  443.         \fBshort\fR type;
  444.         \fBint\fR length;
  445.         \fBint\fR *newlength;
  446.         \fBshort\fR *newtype;
  447. .)b
  448. The function should cast \fIdata\fR to either \fBdouble\fR * or 
  449. \fBcomplex\fR *, depending on whether \fItype\fR is \fIVF_REAL\fR or
  450. \fIVF_COMPLEX\fR. It should set *\fInewtype\fR likewise, depending on
  451. what the result of its application will be, and also it should set
  452. *\fInewlength\fR to the length of the result. There are three types
  453. of functions defined so far - the sort that operate pointwise, where
  454. *\fInewlength\fR = \fIlength\fR, the sort that take a scalar and return
  455. a vector, like \fIcx_vector\fR, where *\fInewlength\fR = something
  456. independent of \fIlength\fR, and the sort that take a vector and
  457. return a scalar, like \fIcx_mean\fR, where *\fInewlength\fR = 1.
  458. .sh 2 "Operations"
  459. .pp
  460. Operations are done in much the same way as complex functions
  461. are done. The routine \fIdoop(func_name, function, arg1, arg2)\fR,
  462. where \fIfunction\fR is a pointer to a function returning a
  463. \fBchar\fR * and \fIarg1\fR and \fIarg2\fR are \fIdvec\fRs, is
  464. used. Complex functions are called as follows:
  465. .(b
  466.     \fBchar\fR *
  467.     cx_operation (data1, data2, type1, type2, length)
  468.         \fBchar\fR *data1, data2;
  469.         \fBshort\fR type1, type2;
  470. .)b
  471. Vectors that are operated on are made the same length. The result
  472. is assumed to be of the same length as the operands and its
  473. type is \fIcomplex\fR if either of the operands is complex.
  474. (The exception to this is the comma operator.)
  475. Adding
  476. new operations requires changing the \fIops\fR table in
  477. "psubr.c", adding the relevant
  478. information to the parser (the files "parse.c" and "getpname.c),
  479. adding a routine like the
  480. ones in "evaluate.c", and perhaps adding a complex function to "cmath.c".
  481. The format of the \fIops\fR table is:
  482. .(b
  483. \fBstruct\fR op {
  484.     \fBint\fR op_num;            /* From parser #defines. */
  485.     \fBchar\fR *op_name;            /* Printing name. */
  486.     \fBchar\fR op_arity;            /* One or two. */
  487.     \fBstruct\fR dvec *(*op_func)();    /* The function to do the work. */
  488. }
  489. .)b
  490. These functions are actually dummy functions that call \fIdoop()\fR
  491. directly.
  492. .pp
  493. The parser is a simple operator-precedence parser.
  494. .sh 2 "Plotting Routines"
  495. .pp
  496. The plotting routines use \fIMFB\fR, the Model Frame Buffer graphics
  497. package. The main stuff is in the file "graf.c".
  498. .sh 2 "Using The Front End With Other Programs"
  499. .pp
  500. The front end may be adapted to use with other circuit-simulation programs
  501. besides \*S without much difficulty. See the manual page for \fBwritedata\fR
  502. for details on how to use this set of routines seperately from the rest of
  503. the front-end.
  504. .pp
  505. All \*S-specific code is in the file "spiceif.c". The following routines
  506. are defined, and should be re-written for another simulator. In general,
  507. pointers to circuits are kept as \fBchar\fR *'s, and are only cast to
  508. the appropriate thing (\fBCKTcircuit\fR *'s for \*S) in the interface
  509. routines.
  510. .(b
  511. if_run(ckt, what)
  512.     char *ckt;
  513.     char *what;
  514. .)b
  515. .pp
  516. This runs a simulation of the circuit. The type of simulation is determined
  517. by the string \fIwhat\fR \- in \*S the possibilities are "tran", "ac",
  518. "dc", "op", "run", and "continue" (continue the run that is already in
  519. progress). XXXXXXXXXXXX
  520. .(b
  521. if_dump(ckt, fp)
  522.     \fBchar\fR *ckt;
  523.     \fBFILE\fR *fp;
  524. .)b
  525. .pp
  526. Do a "dump" of the current circuit \- with \*S now this is just a listing
  527. of what \*S thinks the circuit looks like.
  528. .(b
  529. if_inpline(ckt, line)
  530.     \fBchar\fR *ckt;
  531.     \fBchar\fR *line;
  532. .)b
  533. .pp
  534. Parse the given line and add it to the circuit. Since the \fBINP\fR parser
  535. is incremental this it is possible with \*S to add lines to the circuit
  536. at any point.
  537. .(b
  538. \fBchar\fR *
  539. if_inpdeck(deck)
  540.     \fBstruct\fR card *deck;
  541. .)b
  542. .pp
  543. The \fBcard\fR structure, as defined in "FTEinput.h" is as follows:
  544. .(b
  545. \fBstruct\fR card {
  546.     \fBint\fR ca_linenum;
  547.     \fBchar\fR *ca_line;
  548.     \fBchar\fR *ca_error;
  549.     \fBstruct\fR card *ca_next;
  550.     \fBstruct\fR card *ca_actual;
  551. } ;
  552. .)b
  553. The complete deck is passed to this routine, which has it parsed and returns
  554. a pointer to the circuit structure. See the chapter in the \fBINP\fR parser
  555. for the details of how the card structure works.
  556. .(b
  557. if_option(ckt, name, type, value)
  558.     \fBchar\fR *ckt;
  559.     \fBchar\fR *name;
  560.     \fBint\fR type;
  561.     \fBchar\fR *value;
  562. .)b
  563. .pp
  564. Add an option to the circuit. The \fIname, type,\fR and \fIvalue\fR arguments
  565. are the same as the corresponding fields in the \fIvariable\fR structure.
  566. If the routine can't use the option it should just return.
  567. .(b
  568. if_cktfree(ckt)
  569.     \fBchar\fR *ckt;
  570. .)b
  571. .pp
  572. Free the data occupied by the circuit. This may be a no-op, of course.
  573. .(b
  574. \fBchar\fR *
  575. if_errstring(code)
  576. .)b
  577. .pp
  578. If \fIcode\fR is a number that denotes a particular \*S error, this routine
  579. should return a string describing the error.
  580. .pp
  581. Additionally, there is some code in "subckt.c" and "fourier.c" that refers
  582. to \*S routines, but subcircuit expansion can be easily disabled and the
  583. file "CKTfour.c" taken from \*S for use with the front-end.
  584.  
  585.