1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California.  All rights reserved.
4 Authors: 1987 Thomas L. Quarles
5          1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include "ftedefs.h"
10 #include "inpdefs.h"
11 #include "inpmacs.h"
12 #include "misc.h"
13 
14 
15 /* ARGSUSED */
16 int
TFparse(ckt,tab,which,currentp,line,task,gnode)17 TFparse(ckt,tab,which,currentp,line,task,gnode)
18 
19 /*
20     .tf {vsrc v(node1[,node2])} src [ac {dec oct lin} pts fstart fstop]
21         [ dc SRC1NAME Vstart1 [Vstop1 [Vinc1]]
22         [SRC2NAME Vstart2 [Vstop2 [Vinc2]]] ]
23 */
24 GENERIC *ckt;
25 INPtables *tab;
26 int which;
27 GENERIC *currentp;
28 char **line;
29 GENERIC *task;
30 GENERIC *gnode;
31 {
32     char *token;    /* a token from the line */
33     char *nname1;   /* the first node's name */
34     char *nname2;   /* the second node's name */
35     GENERIC *node;  /* node pointer */
36     GENERIC *foo;   /* pointer to analysis */
37     IFvalue ptemp;  /* a value structure to package stuff into */
38     IFvalue *parm;  /* a pointer to a value struct for function returns */
39     int error;      /* error code temporary */
40     card *current = (card *)currentp;
41 
42     IFC(newAnalysis,(ckt,which,"Transfer Function",&foo,task))
43 
44     INPgetTok(line,&token,0);
45     /* token is now either V or I or a serious error */
46     if (*token == 'v' && strlen(token) == 1) {
47         txfree(token);
48         if (**line != '(' /* match) */ ) {
49             LITERR("Syntax error: '(' expected after 'v'");
50             return (0);
51         }
52         INPgetTok(line,&nname1,0);
53         INPtermInsert(ckt,&nname1,tab,&node);
54         ptemp.nValue = node;
55         GCA(INPapName,(ckt,which,foo,"outpos",&ptemp))
56 
57         if (**line != ')') {
58             INPgetTok(line,&nname2,1);
59             INPtermInsert(ckt,&nname2,tab,&node);
60             ptemp.nValue = node;
61             GCA(INPapName,(ckt,which,foo,"outneg",&ptemp))
62 
63             ptemp.sValue = (char *)
64                 tmalloc(sizeof(char)*(5+strlen(nname1)+strlen(nname2)));
65             (void)sprintf(ptemp.sValue,"v(%s,%s)",nname1,nname2);
66             GCA(INPapName,(ckt,which,foo,"outname",&ptemp))
67         }
68         else {
69             ptemp.nValue = gnode;
70             GCA(INPapName,(ckt,which,foo,"outneg",&ptemp))
71 
72             ptemp.sValue = (char *)tmalloc(sizeof(char)*(4+strlen(nname1)));
73             (void)sprintf(ptemp.sValue,"v(%s)",nname1);
74             GCA(INPapName,(ckt,which,foo,"outname",&ptemp))
75         }
76     }
77     else {
78         INPgetTok(line,&token,1);
79         strtolower(token);
80         INPinsert(&token,tab);
81         ptemp.uValue = token;
82         GCA(INPapName,(ckt,which,foo,"outsrc",&ptemp))
83     }
84     INPgetTok(line,&token,1);
85     strtolower(token);
86     INPinsert(&token,tab);
87     ptemp.uValue = token;
88     GCA(INPapName,(ckt,which,foo,"insrc",&ptemp))
89     if (**line) {
90         INPgetTok(line,&token,1);
91         strtolower(token);
92         if (!strcmp(token,"ac")) {
93             GCA(ParseAC,(ckt,line,current,which,foo,tab))
94         }
95         else if (!strcmp(token,"dc")) {
96             GCA(ParseDC,(ckt,line,current,which,foo,tab,1))
97             if (**line) {
98                 GCA(ParseDC,(ckt,line,current,which,foo,tab,2))
99             }
100             return (0);
101         }
102         else {
103             LITERR("Syntax error: 'ac' or 'dc' expected.")
104         }
105         txfree(token);
106     }
107     if (**line) {
108         INPgetTok(line,&token,1);
109         strtolower(token);
110         if (!strcmp(token,"dc")) {
111             GCA(ParseDC,(ckt,line,current,which,foo,tab,1))
112             if (**line) {
113                 GCA(ParseDC,(ckt,line,current,which,foo,tab,2))
114             }
115         }
116         else {
117             LITERR("Syntax error: 'dc' expected.")
118         }
119         txfree(token);
120     }
121     return (0);
122 }
123