Jspice3
inpaname.c
Go to the documentation of this file.
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: 1985 Thomas L. Quarles
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8  /*
9  * INPaName()
10  *
11  * Take a parameter by Name and ask for the specified value
12  * *dev is -1 if type unknown, otherwise, device type
13  * **fast is a device, and will be set if possible.
14  */
15 
16 #include "spice.h"
17 #include <stdio.h>
18 #include "inpdefs.h"
19 #include "iferrmsg.h"
20 
21 
22 int
23 INPaName(parm,val,ckt,dev,devnam,fast,sim,dataType,selector)
24 
25 char *parm; /* the name of the parameter to set */
26 IFvalue *val; /* the parameter union containing the value to set */
27 GENERIC *ckt; /* the circuit this device is a member of */
28 int *dev; /* the device type code to the device being parsed */
29 char *devnam; /* the name of the device */
30 GENERIC **fast; /* direct pointer to device being parsed */
31 IFsimulator *sim; /* the simulator data structure */
32 int *dataType; /* the datatype of the returned value structure */
33 IFvalue *selector; /* data sub-selector for questions */
34 {
35  int error; /* int to store evaluate error return codes in */
36  int i;
37 
38  /* find the instance - don't know about model, so use null there,
39  * otherwise pass on as much info as we have about the device
40  * (name, type, direct pointer) - the type and direct pointer
41  * WILL be set on return unless error is not OK
42  */
43  error = (*(sim->findInstance))(ckt,dev,fast,devnam,(GENERIC *)NULL,
44  (char *)NULL);
45  if (error) return (error);
46 
47  /* now find the parameter - hunt through the parameter tables for
48  * this device type and look for a name match of an 'ask'able
49  * parameter.
50  */
51  for (i = 0; i < (*(*(sim->devices)[*dev]).numInstanceParms); i++) {
52  if (strcmp(parm,
53  ((*(sim->devices)[*dev]).instanceParms[i].keyword)) == 0 &&
54  (((*(sim->devices)[*dev]).instanceParms[i].dataType)&IF_ASK)) {
55  /* found it, so we ask the question using the device info we got
56  * above and put the results in the IFvalue structure our caller
57  * gave us originally
58  */
59  error = (*(sim->askInstanceQuest))(ckt,*fast,
60  (*(sim->devices)[*dev]).instanceParms[i].id,val,
61  selector);
62  if (dataType)
63  *dataType =
64  (*(sim->devices)[*dev]).instanceParms[i].dataType;
65  return (error);
66  }
67  }
68  return (E_BADPARM);
69 }
int INPaName(char *parm, IFvalue *val, GENERIC *ckt, int *dev, char *devnam, GENERIC **fast, IFsimulator *sim, int *dataType, IFvalue *selector)
Definition: inpaname.c:23
#define IF_ASK
Definition: ifsim.h:136
#define E_BADPARM
Definition: iferrmsg.h:26
IFdevice ** devices
Definition: ifsim.h:461
#define NULL
Definition: spdefs.h:121
char GENERIC
Definition: ifsim.h:27