Jspice3
inpnrefs.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: 1993 Stephen R. Whiteley
5 ****************************************************************************/
6 
7 #include "spice.h"
8 #include "inpdefs.h"
9 
10 int
11 INPnumRefs(c,terms,devs,soft,hasmod)
12 
13 /*
14  * Find the number of nodes used by the device keyed by c, and the
15  * number of devices referenced. Also the soft flag, and whether the
16  * device has a model.
17  */
18 int c;
19 int *terms, *devs;
20 int *soft, *hasmod;
21 {
22  int i, j;
23  IFdevice *dev;
24 
25  if (isalpha(c)) {
26  if (isupper(c)) c = tolower(c);
27 
28  for (i = 0; i < ft_sim->numDevices; i++) {
29  dev = ft_sim->devices[i];
30  for (j = 0; j < *dev->numKeys; j++) {
31  if (dev->keys[j].key == c)
32  break;
33  }
34  if (j < *dev->numKeys) {
35  if (terms) *terms = dev->keys[j].numTerms;
36  if (devs) *devs = dev->keys[j].numDevs;
37  if (soft) *soft = dev->keys[j].soft;
38  if (hasmod) *hasmod = (dev->modelKeys ? 1 : 0);
39  return (1);
40  }
41  }
42  }
43  if (terms) *terms = 0;
44  if (devs) *devs = 0;
45  if (soft) *soft = 0;
46  if (hasmod) *hasmod = 0;
47  return (0);
48 }
IFkeys * keys
Definition: ifsim.h:297
IFsimulator * ft_sim
Definition: main.c:111
int soft
Definition: ifsim.h:271
int numTerms
Definition: ifsim.h:269
IFdevice ** devices
Definition: ifsim.h:461
char ** modelKeys
Definition: ifsim.h:305
char key
Definition: ifsim.h:268
int INPnumRefs(int c, int *terms, int *devs, int *soft, int *hasmod)
Definition: inpnrefs.c:11
Definition: cddefs.h:177
int numDevs
Definition: ifsim.h:272
int * numKeys
Definition: ifsim.h:296
int numDevices
Definition: ifsim.h:460