some cleanup
This commit is contained in:
parent
3a319212f3
commit
56f77e45f5
|
|
@ -6,92 +6,95 @@ Author: 1985 Thomas L. Quarles
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <cktdefs.h>
|
#include <cktdefs.h>
|
||||||
#include <sperror.h>
|
#include <sperror.h>
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
CKTfndDev(void *Ckt, int *type, void **fast, IFuid name, void *modfast, IFuid modname)
|
CKTfndDev(void *Ckt, int *type, void **fast, IFuid name, void *modfast, IFuid modname)
|
||||||
{
|
{
|
||||||
CKTcircuit *ckt=(CKTcircuit *)Ckt;
|
CKTcircuit *ckt=(CKTcircuit *)Ckt;
|
||||||
GENinstance *here;
|
GENinstance *here;
|
||||||
GENmodel *mods;
|
GENmodel *mods;
|
||||||
|
|
||||||
if((GENinstance **)fast != (GENinstance **)NULL &&
|
if((GENinstance **)fast != (GENinstance **)NULL &&
|
||||||
*(GENinstance **)fast != (GENinstance *)NULL) {
|
*(GENinstance **)fast != (GENinstance *)NULL)
|
||||||
/* already have fast, so nothing much to do just get & set
|
{
|
||||||
type */
|
/* already have fast, so nothing much to do just get & set type */
|
||||||
if (type)
|
if (type)
|
||||||
*type = (*((GENinstance**)fast))->GENmodPtr->GENmodType;
|
*type = (*((GENinstance**)fast))->GENmodPtr->GENmodType;
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modfast) {
|
if(modfast) {
|
||||||
/* have model, just need device */
|
/* have model, just need device */
|
||||||
mods = (GENmodel*)modfast;
|
mods = (GENmodel*)modfast;
|
||||||
for (here = mods->GENinstances;
|
for (here = mods->GENinstances; here != NULL; here = here->GENnextInstance) {
|
||||||
here != NULL;
|
if (here->GENname == name) {
|
||||||
here = here->GENnextInstance) {
|
if (fast != NULL)
|
||||||
if (here->GENname == name) {
|
*(GENinstance **)fast = here;
|
||||||
if (fast != NULL)
|
|
||||||
*(GENinstance **)fast = here;
|
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
*type = mods->GENmodType;
|
*type = mods->GENmodType;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return E_NODEV;
|
return E_NODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*type >= 0 && *type < DEVmaxnum) {
|
if (*type >= 0 && *type < DEVmaxnum) {
|
||||||
/* have device type, need to find model & device */
|
/* have device type, need to find model & device */
|
||||||
/* look through all models */
|
/* look through all models */
|
||||||
for (mods = (GENmodel *)ckt->CKThead[*type];
|
for (mods = (GENmodel *)ckt->CKThead[*type];
|
||||||
mods != NULL ;
|
mods != NULL ;
|
||||||
mods = mods->GENnextModel) {
|
mods = mods->GENnextModel)
|
||||||
|
{
|
||||||
|
/* and all instances */
|
||||||
|
if (modname == (char *)NULL || mods->GENmodName == modname) {
|
||||||
|
for (here = mods->GENinstances;
|
||||||
|
here != NULL;
|
||||||
|
here = here->GENnextInstance)
|
||||||
|
{
|
||||||
|
if (here->GENname == name) {
|
||||||
|
if (fast != 0)
|
||||||
|
*(GENinstance **)fast = here;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mods->GENmodName == modname) {
|
||||||
|
return E_NODEV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return E_NOMOD;
|
||||||
|
} else if (*type == -1) {
|
||||||
|
/* look through all types (UGH - worst case - take forever) */
|
||||||
|
for(*type = 0; *type < DEVmaxnum; (*type)++) {
|
||||||
|
/* need to find model & device */
|
||||||
|
/* look through all models */
|
||||||
|
for(mods=(GENmodel *)ckt->CKThead[*type];mods!=NULL;
|
||||||
|
mods = mods->GENnextModel)
|
||||||
|
{
|
||||||
/* and all instances */
|
/* and all instances */
|
||||||
if (modname == (char *)NULL || mods->GENmodName == modname) {
|
if(modname == (char *)NULL || mods->GENmodName == modname) {
|
||||||
for (here = mods->GENinstances;
|
for (here = mods->GENinstances;
|
||||||
here != NULL;
|
here != NULL;
|
||||||
here = here->GENnextInstance) {
|
here = here->GENnextInstance)
|
||||||
if (here->GENname == name) {
|
{
|
||||||
if (fast != 0)
|
if (here->GENname == name) {
|
||||||
*(GENinstance **)fast = here;
|
if(fast != 0)
|
||||||
return OK;
|
*(GENinstance **)fast = here;
|
||||||
}
|
return OK;
|
||||||
}
|
}
|
||||||
if(mods->GENmodName == modname) {
|
}
|
||||||
return E_NODEV;
|
if(mods->GENmodName == modname) {
|
||||||
}
|
return E_NODEV;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return E_NOMOD;
|
}
|
||||||
} else if (*type == -1) {
|
*type = -1;
|
||||||
/* look through all types (UGH - worst case - take forever) */
|
return E_NODEV;
|
||||||
for(*type = 0; *type < DEVmaxnum; (*type)++) {
|
} else
|
||||||
/* need to find model & device */
|
return E_BADPARM;
|
||||||
/* look through all models */
|
|
||||||
for(mods=(GENmodel *)ckt->CKThead[*type];mods!=NULL;
|
|
||||||
mods = mods->GENnextModel) {
|
|
||||||
/* and all instances */
|
|
||||||
if(modname == (char *)NULL || mods->GENmodName == modname) {
|
|
||||||
for (here = mods->GENinstances;
|
|
||||||
here != NULL;
|
|
||||||
here = here->GENnextInstance) {
|
|
||||||
if (here->GENname == name) {
|
|
||||||
if(fast != 0)
|
|
||||||
*(GENinstance **)fast = here;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(mods->GENmodName == modname) {
|
|
||||||
return E_NODEV;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*type = -1;
|
|
||||||
return E_NODEV;
|
|
||||||
} else
|
|
||||||
return E_BADPARM;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue