inpcom.c, add function inp_check_scope_mod()

This commit is contained in:
h_vogt 2016-04-27 16:40:55 +02:00 committed by rlar
parent df3424d80d
commit f70c563728
1 changed files with 19 additions and 0 deletions

View File

@ -150,6 +150,7 @@ static char *inp_pathresolve_at(char *name, char *dir);
static char *search_plain_identifier(char *str, const char *identifier);
void tprint(struct line *deck, int numb);
static void inp_add_levels(struct line *deck);
bool inp_check_scope_mod(unsigned short elem_level[], unsigned short mod_level[]);
struct inp_read_t
{ struct line *cc;
@ -6761,3 +6762,21 @@ inp_add_levels(struct line *deck)
}
}
}
/* return TRUE if element is within scope of model */
bool
inp_check_scope_mod(unsigned short elem_level[], unsigned short mod_level[])
{
int i;
/* model at top level, accessible from all devices */
if (mod_level[0] == 0)
return TRUE;
/* model at nesting level */
for (i = 0; i < NESTINGDEPTH - 1; i++)
if ((elem_level[i] > 0) && (elem_level[i] == mod_level[i]) && (mod_level[i + 1] == 0))
return TRUE;
if ((elem_level[NESTINGDEPTH - 1] > 0) && (elem_level[NESTINGDEPTH - 1] == mod_level[NESTINGDEPTH - 1]))
return TRUE;
return FALSE;
}