CKTfndDev(), #1/6, whitespace

This commit is contained in:
rlar 2013-06-30 12:47:24 +02:00
parent 025c1e751e
commit 8a69f5c1c8
1 changed files with 64 additions and 64 deletions

View File

@ -24,79 +24,79 @@ find_instance(GENinstance *here, IFuid name)
int int
CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast, IFuid modname) CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast, IFuid modname)
{ {
GENinstance *here; GENinstance *here;
GENmodel *mods; GENmodel *mods;
if(fast != NULL && if (fast != NULL &&
*fast != NULL) *fast != 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 = (*fast)->GENmodPtr->GENmodType; *type = (*fast)->GENmodPtr->GENmodType;
return(OK); return(OK);
} }
if(modfast) { if (modfast) {
/* have model, just need device */ /* have model, just need device */
mods = modfast; mods = modfast;
here = find_instance(mods->GENinstances, name); here = find_instance(mods->GENinstances, name);
if (here) { if (here) {
if (fast != NULL) if (fast != NULL)
*fast = here; *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 = ckt->CKThead[*type]; for (mods = ckt->CKThead[*type];
mods != NULL ; mods != NULL ;
mods = mods->GENnextModel) mods = mods->GENnextModel)
{ {
/* and all instances */
if (modname == NULL || mods->GENmodName == modname) {
here = find_instance(mods->GENinstances, name);
if (here) {
if (fast != 0)
*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 = ckt->CKThead[*type]; mods != NULL;
mods = mods->GENnextModel)
{
/* and all instances */ /* and all instances */
if(modname == NULL || mods->GENmodName == modname) { if (modname == NULL || mods->GENmodName == modname) {
here = find_instance(mods->GENinstances, name); here = find_instance(mods->GENinstances, name);
if (here) { if (here) {
if(fast != 0) if (fast != 0)
*fast = here; *fast = here;
return OK; return OK;
} }
if(mods->GENmodName == modname) { if (mods->GENmodName == modname) {
return E_NODEV; return E_NODEV;
} }
} }
} }
} return E_NOMOD;
*type = -1; } else if (*type == -1) {
return E_NODEV; /* look through all types (UGH - worst case - take forever) */
} else for (*type = 0; *type < DEVmaxnum; (*type)++) {
return E_BADPARM; /* need to find model & device */
/* look through all models */
for (mods = ckt->CKThead[*type]; mods != NULL;
mods = mods->GENnextModel)
{
/* and all instances */
if (modname == NULL || mods->GENmodName == modname) {
here = find_instance(mods->GENinstances, name);
if (here) {
if (fast != 0)
*fast = here;
return OK;
}
if (mods->GENmodName == modname) {
return E_NODEV;
}
}
}
}
*type = -1;
return E_NODEV;
} else
return E_BADPARM;
} }