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

Go to the source code of this file.

Functions

int CKTcrtElt (GENERIC *ckt, GENERIC *inModPtr, GENERIC **inInstPtr, IFuid name)
 

Function Documentation

int CKTcrtElt ( GENERIC ckt,
GENERIC inModPtr,
GENERIC **  inInstPtr,
IFuid  name 
)

Definition at line 23 of file cktcrte.c.

29 {
30  GENinstance *instPtr = NULL;
31  GENmodel *modPtr=(GENmodel*)inModPtr;
32  extern SPICEdev *DEVices[];
33  int error;
34  int type;
35 
36  if ((GENmodel *)modPtr == (GENmodel*)NULL) return(E_NOMOD);
37  type = ((GENmodel*)modPtr)->GENmodType;
38  error =
39  CKTfndDev(ckt,&type,(GENERIC**)&instPtr,name,inModPtr,(char *)NULL);
40  if (error == OK) {
41  if (inInstPtr) *inInstPtr = (GENERIC *)instPtr;
42  return (E_EXISTS);
43  }
44  else if (error != E_NODEV) return (error);
45  instPtr = (GENinstance *)MALLOC(*DEVices[type]->DEVinstSize);
46  if (instPtr == (GENinstance *)NULL) return (E_NOMEM);
47  instPtr->GENname = name;
48  instPtr->GENmodPtr = modPtr;
49  instPtr->GENnextInstance = modPtr->GENinstances;
50  modPtr->GENinstances = instPtr;
51  if (inInstPtr != NULL) *inInstPtr = (GENERIC *)instPtr;
52  return (OK);
53 }
#define E_NODEV
Definition: iferrmsg.h:22
SPICEdev * DEVices[]
Definition: sconfig.c:109
struct sGENinstance * GENnextInstance
Definition: gendefs.h:26
#define E_EXISTS
Definition: iferrmsg.h:20
#define OK
Definition: iferrmsg.h:17
#define MALLOC(x)
Definition: util.h:9
#define NULL
Definition: spdefs.h:121
#define E_NOMEM
Definition: iferrmsg.h:27
#define E_NOMOD
Definition: iferrmsg.h:23
int type
Definition: cktdefs.h:56
int CKTfndDev()
struct sGENmodel * GENmodPtr
Definition: gendefs.h:25
GENinstance * GENinstances
Definition: gendefs.h:43
IFuid GENname
Definition: gendefs.h:28
char GENERIC
Definition: ifsim.h:27