Jspice3
cktfndm.c File Reference
#include "spice.h"
#include <stdio.h>
#include <math.h>
#include "cktdefs.h"
#include "sperror.h"
#include "util.h"
#include "cktext.h"
Include dependency graph for cktfndm.c:

Go to the source code of this file.

Functions

int CKTfndMod (GENERIC *ckt, int *type, GENERIC **modfast, IFuid modname)
 

Function Documentation

int CKTfndMod ( GENERIC ckt,
int *  type,
GENERIC **  modfast,
IFuid  modname 
)

Definition at line 18 of file cktfndm.c.

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 }
#define E_BADPARM
Definition: iferrmsg.h:26
struct sGENmodel * GENnextModel
Definition: gendefs.h:41
#define OK
Definition: iferrmsg.h:17
#define NULL
Definition: spdefs.h:121
Definition: types.c:18
#define E_NOMOD
Definition: iferrmsg.h:23
int DEVmaxnum
Definition: sconfig.c:166
IFuid GENmodName
Definition: gendefs.h:45