diff options
author | 2013-02-01 16:27:43 +0100 | |
---|---|---|
committer | 2013-02-01 16:27:43 +0100 | |
commit | 9d9098764e8d6f52ed506d500c061bb9878a62c8 (patch) | |
tree | f0647cb579b853dfa6e489ae0825a92bacf0b562 /ufed-curses-types.c | |
parent | Fixed F-Key descriptions (diff) | |
download | ufed-9d9098764e8d6f52ed506d500c061bb9878a62c8.tar.gz ufed-9d9098764e8d6f52ed506d500c061bb9878a62c8.tar.bz2 ufed-9d9098764e8d6f52ed506d500c061bb9878a62c8.zip |
Added a post-load analyzation to make use flags, that have only local descriptions which are all masked and/or forced unchangeable.
Diffstat (limited to 'ufed-curses-types.c')
-rw-r--r-- | ufed-curses-types.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ufed-curses-types.c b/ufed-curses-types.c index 7b208fa..c80b9dd 100644 --- a/ufed-curses-types.c +++ b/ufed-curses-types.c @@ -224,6 +224,50 @@ void destroyFlag (sFlag** root, sFlag** flag) } +/** @brief generate globalMasked and globalForced + * This function checks whether either the first global description, + * or all local descriptions with no available global description of + * a flag is/are masked and/or forced and sets the global states + * accordingly. + * @param[in,out] flag pointer to the flag to check + */ +void genFlagStats (sFlag* flag) +{ + if (flag) { + bool hasLocal = false; + bool hasGlobal = false; + bool allLocalMasked = true; + bool allLocalForced = true; + for (int i = 0; + (!hasGlobal || allLocalMasked || allLocalForced) + && (i < flag->ndesc) + ; ++i) { + if (flag->desc[i].isGlobal) { + hasGlobal = true; + if ('+' == flag->desc[i].stateForced) + flag->globalForced = true; + if ('+' == flag->desc[i].stateMasked) + flag->globalMasked = true; + } else { + hasLocal = true; + if ('+' != flag->desc[i].stateForced) + allLocalForced = false; + if ('+' != flag->desc[i].stateMasked) + allLocalMasked = false; + } + } + + // Now if there is no global description, + // the "global" settings are taken from the + // local ones. + if (!hasGlobal && hasLocal) { + flag->globalForced = allLocalForced; + flag->globalMasked = allLocalMasked; + } + } +} + + /** @brief determine the number of lines used by @a flag * This method checks the flag and its description line(s) * settings against the globally active filters. |