Jspice3
cktfndm.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 #include "spice.h"
9 #include <stdio.h>
10 #include <math.h>
11 #include "cktdefs.h"
12 #include "sperror.h"
13 #include "util.h"
14 #include "cktext.h"
15 
16 
17 int
18 CKTfndMod(ckt,type,modfast,modname)
19 
20 GENERIC *ckt;
21 int *type;
22 GENERIC **modfast;
23 IFuid modname;
24 {
25  GENmodel *mods;
26 
27  if (modfast != NULL && *(GENmodel **)modfast != NULL) {
28  /* already have modfast, so nothing to do */
29  if (type) *type = (*(GENmodel **)modfast)->GENmodType;
30  return (OK);
31  }
32  if (*type >=0 && *type < DEVmaxnum) {
33  /* have device type, need to find model */
34  /* look through all models */
35  for (mods = ((CKTcircuit *)ckt)->CKThead[*type]; mods != NULL ;
36  mods = mods->GENnextModel) {
37  if (mods->GENmodName == modname) {
38  *modfast = (char *)mods;
39  return (OK);
40  }
41  }
42  return (E_NOMOD);
43  }
44  else if(*type == -1) {
45  /* look through all types (UGH - worst case - take forever) */
46  for (*type = 0; *type < DEVmaxnum; (*type)++) {
47  /* need to find model & device */
48  /* look through all models */
49  for (mods = ((CKTcircuit *)ckt)->CKThead[*type]; mods!=NULL;
50  mods = mods->GENnextModel) {
51  if (mods->GENmodName == modname) {
52  *modfast = (char *)mods;
53  return (OK);
54  }
55  }
56  }
57  *type = -1;
58  return (E_NOMOD);
59  }
60  else
61  return (E_BADPARM);
62 }
int CKTfndMod(GENERIC *ckt, int *type, GENERIC **modfast, IFuid modname)
Definition: cktfndm.c:18
#define E_BADPARM
Definition: iferrmsg.h:26
struct sGENmodel * GENnextModel
Definition: gendefs.h:41
#define OK
Definition: iferrmsg.h:17
GENERIC * IFuid
Definition: ifsim.h:72
#define NULL
Definition: spdefs.h:121
Definition: types.c:18
#define E_NOMOD
Definition: iferrmsg.h:23
int GENmodType
Definition: gendefs.h:40
int DEVmaxnum
Definition: sconfig.c:166
char GENERIC
Definition: ifsim.h:27
IFuid GENmodName
Definition: gendefs.h:45