Jspice3
Main Page
Data Structures
Files
File List
Globals
inpdpar.c
Go to the documentation of this file.
1
/***************************************************************************
2
JSPICE3 adaptation of Spice3e2 - 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
1992 Stephen R. Whiteley
6
****************************************************************************/
7
8
/*
9
* INPdevParse()
10
*
11
* parse a given input according to the standard rules - look
12
* for the parameters given in the parmlists, In addition,
13
* an optional leading numeric parameter is handled.
14
*/
15
16
#include "
spice.h
"
17
#include "
inpdefs.h
"
18
#include "
iferrmsg.h
"
19
#include "
misc.h
"
20
21
22
char
*
23
INPdevParse
(
line
,ckt,dev,fast,leading,waslead,
tab
)
24
25
char **
line
;
/* the line to parse */
26
GENERIC
*ckt;
/* the circuit this device is a member of */
27
int
dev;
/* the device type code to the device being parsed */
28
GENERIC
*fast;
/* direct pointer to device being parsed */
29
double
*leading;
/* the optional leading numeric parameter */
30
int
*waslead;
/* flag - 1 if leading double given, 0 otherwise */
31
INPtables
*
tab
;
32
{
33
int
error;
/* int to store evaluate error return codes in */
34
char
*parm;
35
char
*errbuf;
36
int
i;
37
IFvalue
*val;
38
IFdevice
*
device
=
ft_sim
->
devices
[dev];
39
40
/* check for leading value */
41
*waslead = 0;
42
*leading =
INPevaluate
(line,&error,1);
43
44
if
(error == 0)
45
/* found a good leading number */
46
*waslead = 1;
47
else
48
*leading = 0.0;
49
50
51
while
(**line != (
char
) 0) {
52
error =
INPgetTok
(line,&parm,1);
53
if
(error)
54
return
(
INPerror
(error));
55
56
for
(i = 0; i < *device->
numInstanceParms
; i++) {
57
if
(!strcmp(parm,device->
instanceParms
[i].
keyword
)) {
58
59
val =
INPgetValue
(ckt,line,
60
device->
instanceParms
[i].
dataType
,tab);
61
if
(!val) {
62
txfree
(parm);
63
return
(
INPerror
(
E_PARMVAL
));
64
}
65
error = (*(
ft_sim
->setInstanceParm))(ckt,fast,
66
device->
instanceParms
[i].
id
,
67
val,(
IFvalue
*)
NULL
);
68
if
(error) {
69
txfree
(parm);
70
return
(
INPerror
(error));
71
}
72
break
;
73
}
74
}
75
if
(i == *device->
numInstanceParms
) {
76
errbuf =
tmalloc
(strlen(parm)+25);
77
(void)sprintf(errbuf,
"Unknown parameter (%s)"
,parm);
78
txfree
(parm);
79
return
(errbuf);
80
}
81
txfree
(parm);
82
}
83
return
((
char
*)
NULL
);
84
}
device
DISPDEVICE device[]
Definition:
display.c:24
INPerror
char * INPerror()
ft_sim
IFsimulator * ft_sim
Definition:
main.c:111
misc.h
sIFdevice::numInstanceParms
int * numInstanceParms
Definition:
ifsim.h:312
INPgetValue
IFvalue * INPgetValue()
sIFdevice
Definition:
ifsim.h:292
sIFdevice::instanceParms
IFparm * instanceParms
Definition:
ifsim.h:313
INPevaluate
double INPevaluate()
tab
Definition:
subckt.c:51
tmalloc
char * tmalloc()
line
Definition:
fteinp.h:14
E_PARMVAL
#define E_PARMVAL
Definition:
iferrmsg.h:32
sIFsimulator::devices
IFdevice ** devices
Definition:
ifsim.h:461
sIFparm::id
int id
Definition:
ifsim.h:56
txfree
void txfree()
NULL
#define NULL
Definition:
spdefs.h:121
inpdefs.h
spice.h
iferrmsg.h
sIFparm::dataType
int dataType
Definition:
ifsim.h:57
uIFvalue
Definition:
ifsim.h:231
sIFparm::keyword
char * keyword
Definition:
ifsim.h:55
INPdevParse
char * INPdevParse(char **line, GENERIC *ckt, int dev, GENERIC *fast, double *leading, int *waslead, INPtables *tab)
Definition:
inpdpar.c:23
sINPtables
Definition:
inpdefs.h:30
GENERIC
char GENERIC
Definition:
ifsim.h:27
INPgetTok
int INPgetTok()
src
lib
inp
inpdpar.c
Generated by
1.8.11