From 38e68869a29012c2813b027f2ffbc84408b69bbb Mon Sep 17 00:00:00 2001 From: pnenzi Date: Wed, 1 Mar 2006 14:30:24 +0000 Subject: [PATCH] Added mdel, del and dest functions to interface. --- .../devices/adms/admst/ngspiceMODULEdel.c.xml | 97 +++++++++++++++++ .../adms/admst/ngspiceMODULEdest.c.xml | 97 +++++++++++++++++ .../adms/admst/ngspiceMODULEinit.c.xml | 12 +- .../adms/admst/ngspiceMODULEmdel.c.xml | 103 ++++++++++++++++++ .../devices/adms/admst/ngspiceMakefile.am.xml | 21 +++- 5 files changed, 322 insertions(+), 8 deletions(-) create mode 100644 src/spicelib/devices/adms/admst/ngspiceMODULEdel.c.xml create mode 100644 src/spicelib/devices/adms/admst/ngspiceMODULEdest.c.xml create mode 100644 src/spicelib/devices/adms/admst/ngspiceMODULEmdel.c.xml diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEdel.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEdel.c.xml new file mode 100644 index 000000000..a8eb7980c --- /dev/null +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEdel.c.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +#include "ngspice.h" +#include "$(module)defs.h" +#include "sperror.h" +#include "suffix.h" + +int $(module)delete(GENmodel *inModel, IFuid name, GENinstance **inInst) + +{ + register $(module)model *model = ($(module)model*)inModel; + register $(module)instance **fast =($(module)instance**)inInst; + + $(module)instance **prev = NULL; + $(module)instance *here; + + for ( ; model ; model = model->$(module)nextModel ) { + prev = &(model->$(module)instances); + for (here = *prev; here ; here = *prev) { + if(here->$(module)name == name || (fast && here==*fast) ) { + *prev = here->$(module)nextInstance; + FREE(here); + return(OK); + } + + } + } + return(E_NODEV); +} + + + + + + + + + + + + + + + + + + diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEdest.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEdest.c.xml new file mode 100644 index 000000000..09f47c453 --- /dev/null +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEdest.c.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +#include "ngspice.h" +#include "$(module)defs.h" +#include "suffix.h" + +void $(module)destroy(GENmodel **inModel) + +{ + register $(module)model **model = ($(module)model**)inModel; + register $(module)instance *here; + $(module)instance *prev = NULL; + $(module)model *mod = *model; + $(module)model *oldmod = NULL; + + for ( ; mod ; mod = mod->$(module)nextModel ) { + if (oldmod) FREE(oldmod); + oldmod = mod; + prev = ($(module)instance *)NULL; + for (here = mod->$(module)instances; here ; here = here->$(module)nextInstance) { + if(prev) FREE(prev); + prev = here; + } + if(prev) FREE(prev); + } + if(oldmod) FREE(oldmod); + *model = NULL; + return; +} + + + + + + + + + + + + + + + + + + diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEinit.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEinit.c.xml index 51ebfb811..6a26d6f79 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULEinit.c.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEinit.c.xml @@ -3,7 +3,11 @@ + + + + + + + + + + + + + + + + + + + + + + + + +#include "ngspice.h" +#include "$(module)defs.h" +#include "sperror.h" +#include "suffix.h" + +int $(module)mDelete(GENmodel **inModel, IFuid modname, GENmodel *kill) + +{ + register $(module)model **model = ($(module)model**)inModel; + register $(module)model *modfast =($(module)model*)kill; + $(module)instance *here; + $(module)instance *prev = NULL; + $(module)model **oldmod; + + oldmod = model; + for ( ; *model ; model = &((*model)->$(module)nextModel)) { + if ((*model)->$(module)modName == modname || + (modfast && *model == modfast)) + goto delgot; + oldmod = model; + } + return(E_NOMOD); + + delgot: + *oldmod = (*model)->$(module)nextModel; /* cut deleted device out of list */ + for (here = (*model)->$(module)instances; here; here = here->$(module)nextInstance) + { if(prev) FREE(prev); + prev = here; + } + if(prev) FREE(prev); + FREE(*model); + return(OK); +} + + + + + + + + + + + + + + + + + + diff --git a/src/spicelib/devices/adms/admst/ngspiceMakefile.am.xml b/src/spicelib/devices/adms/admst/ngspiceMakefile.am.xml index 6ee29c6f1..ed7b203e0 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMakefile.am.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMakefile.am.xml @@ -3,7 +3,11 @@